I’m struggling to get a small EditText along with two buttons aligned to the bottom of the screen or bottom of software keyboard. Basically my problem is that every time I open up my activity (flagged with adjustResize | stateAlwaysVisible) and layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="bottom"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_alignParentBottom="true">
<LinearLayout android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/soft_input_edit_placeholder">
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/editText1">
<requestFocus></requestFocus>
</EditText>
</LinearLayout>
<LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:weightSum="2" android:id="@+id/soft_input_layout_buttons">
<Button android:layout_width="0dp" android:text="xxx Submit xxx" android:layout_height="wrap_content" android:id="@+id/soft_input_button_submit" android:layout_weight="1"></Button>
<Button android:layout_width="0dp" android:text="xxx Cancel xxx" android:layout_height="wrap_content" android:id="@+id/soft_input_button_cancel" android:layout_weight="1"></Button>
</LinearLayout>
</LinearLayout>
The keyboard slides up, it resizes the activity so that only the edit text is visible, and when I hide it (at least the keyboard has a button that allows me to hide it), layout remains in position, that is, it never slides back down, leaving half of the screen uncovered.
I read that in most cases the alignment is achieved by introducing some scalable control to the layout, but I don’t really wish to have any form of ListView there; I tried using RelativeLayout, still no go. Embedding one into the other – still no luck. I’d be very thankful for any suggestions you may have, I’m running out of ideas..
Thank you!
The problem was all in selected themes. My activity had a full-screen theme applied in the manifest (and I had no idea it might affect the view in this way); changing it to non-fullscreen has solved my problems (although it can’t be just any other theme)
I achieved my goal by setting activity theme to Theme.Translucent and layout theme to Theme (no theme at all); applying @android:drawable/bottom_bar to the main LinearLayout and finally setting the main layout’s gravity to bottom gave me the results I was looking for.