Let's say I have this simple layout:
https://i.stack.imgur.com/QM9i7.jpg
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="80dp"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher" />
...
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Eighth" />
</LinearLayout>
</ScrollView>
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_margin="16dp"
android:text="Button" />
</RelativeLayout>
Note there is paddingBottom
on ScrollView
with clipToPadding=false
. It's needed so Button
looks like floating button over scroll view content. ScrollView padding is used to make space below content to make last child available.
If the last child is EditText
I expect ScrollView
to scroll making EditText
visible over software keyboard. But it ends with this https://i.stack.imgur.com/3hwNy.jpg
Kind of expected behavior can be achieved using layout_marginBottom
instead of paddingBottom
, but in this case obviously I can't see my content behind Button
. Screenshot https://i.stack.imgur.com/KPPwy.jpg
Is there a way to make ScrollView
to respect its paddings in terms of keyboard avoiding?
UPDATE: full xml code here https://pastebin.com/P8n0aZ2i