Android: How to align the button to the bottom and above the keyboard when it is installed?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <EditText android:id="@+id/editTextTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/task_title" android:ems="10" > <requestFocus /> </EditText> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"> <Button android:id="@+id/buttonSeven" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="7" /> </RelativeLayout> 

Trying to align a few buttons at the bottom of the screen. However, when the keyboard appears, I want the buttons to move up above the keyboard. How to do it?

+6
source share
2 answers

In your AndroidManifest.xml just add this attribute: Android: windowSoftInputMode = "adjustResize"

 <activity android:windowSoftInputMode="adjustResize" android:name="com.example.stackoverflow.SimpleActivity5" > 
+17
source

You need to annotate the action in the manifest. See the manifest documentation for the android: windowSoftInputMode attribute , you need to specify android:windowSoftInputMode="adjustResize" so that when you display the keyboard, the viewport for your activity changes to the area above the keyboard and hey presto! buttons will appear.

+2
source

Source: https://habr.com/ru/post/946184/


All Articles