user4400167
user4400167

Reputation:

RelativeLayout is not autosizing when keyboard is shown

RelativeLayout is not autosizable when keyboard is shown:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="wrap_content" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

<EditText
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/editText"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:imeOptions="flagNoFullscreen|flagNoExtractUi"
    android:inputType="none"
    android:minLines="1"
    android:maxLines="1" />

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/scrollView"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_above="@+id/editText" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:id="@+id/textView"
        android:fontFamily="Courier New" />
</ScrollView>

</RelativeLayout>

When keyboard is shown elements not autosizes: When keyboard is hidden

When keyboard is shown

When keyboard is shown, content is beyond of top of phone

Upvotes: 1

Views: 291

Answers (2)

Md Imran Choudhury
Md Imran Choudhury

Reputation: 9997

Add android:windowSoftInputMode="adjustPan" to your manifest:

  <activity android:name="MyActivity"
    ...
    android:windowSoftInputMode="adjustPan"
    ...
  </activity>

Upvotes: 0

khaleel_jageer
khaleel_jageer

Reputation: 1502

add this property to your root layout(Relative layout):

android:fitsSystemWindows="true"

and also add android:windowSoftInputMode="adjustResize" to activity tag in your Manifest file.

Upvotes: 1

Related Questions