Let's say I have this simple layout:
<?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://imgur.com/GwOtLIq
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://imgur.com/oSC24qV
What I want to achieve is https://imgur.com/undefined on keyboard show.
Is there a way to make ScrollView to respect its paddings in terms of keyboard avoiding?
from ScrollView padding ignored on keyboard show
No comments:
Post a Comment