Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

<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 pops up, I want the buttons to move up to above the keyboard. How to do that?

like image 853
tipsywacky Avatar asked May 30 '13 13:05

tipsywacky


People also ask

How do I keep the button on the bottom of my screen android?

Make the Parent of the LinearLayout containing the button as relative and set the property of linear layout containing two buttons as android:layout_alignParentBottom="true". You can also set the gravity of the Linear Layout to Bottom.

How do I center a button on android?

If you have a single Button in your Activity and you want to center it the simplest way is to use a RelativeLayout and set the android:layout_centerInParent=”true” property on the Button.

How do I get the EditText above my keyboard?

After research I figured out that to work in some cases parent layout has to be set android:fitsSystemWindows="true" . Then native functionality of scrolling EditText above scrollbar working like a charm. Show activity on this post. Simply setting android:fitsSystemWindows="true" in the layout xml worked for me.


1 Answers

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

<activity 
            android:windowSoftInputMode="adjustResize"
            android:name="com.example.stackoverflow.SimpleActivity5" >
like image 141
Jarvis Avatar answered Nov 25 '22 15:11

Jarvis