Search code examples
androidkeyboardandroid-edittext

Android TextAlignment in EditText stops keyboard lifting up


I have strange problem. When I set Text Alignment of my EditText to center the keyboard is not lifting it up. EditText stays behind the keyboard ( is hidden). Why is that? What I should do to lift the EditText above the keyboard. EditText is placed in LinearLayout and that all is placed in FrameLayout at the bottom. Thank you!

Edit (code of layout):

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"   

  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".ProfileChooseActivity"
  android:scrollIndicators="none"
  android:background="@drawable/bg_run4">

  <!-- The primary full-screen view. This can be replaced with whatever view
     is needed to present your content, e.g. VideoView, SurfaceView,
     TextureView, etc. -->

  <!-- This FrameLayout insets its children based on system windows using
     android:fitsSystemWindows. -->

  <LinearLayout
    android:orientation="vertical"
    android:layout_width="233dp"
    android:layout_height="159dp"
    android:layout_gravity="start|bottom"
    android:layout_margin="10dp">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:ems="10"
        android:id="@+id/profileNameEditText"
        android:layout_margin="10dp"
        android:backgroundTint="#97f8720b"
        android:hint="@string/profile_name"
        android:textCursorDrawable="@null"
        android:layout_marginTop="20dp"
        android:textColor="#3d3131"
        android:textAlignment="center"/>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/enter_profile"
        android:id="@+id/enterProfileButton"
        android:layout_gravity="center_horizontal"
        android:background="#97f8720b"
        android:singleLine="false"
        android:clickable="true"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
         />
  </LinearLayout>
</FrameLayout>

Solution

  • I replicated the layout file as you described and everything is working. May be there is a problem with your layout.

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:orientation="vertical">
    
        <EditText
            android:id="@+id/edittext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:textAlignment="center"/>
    
    </LinearLayout>
    
    </FrameLayout>
    

    enter image description here