Допустим, у меня есть такая простая раскладка:
https://imgur.com/k6zuh3f
<?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>
Обратите внимание, что paddingBottom
на ScrollView
с clipToPadding=false
. Это необходимо, чтобы Button
выглядел как плавающая кнопка над прокруткой. Заполнение ScrollView используется, чтобы освободить место под содержимым, чтобы сделать доступным последний дочерний элемент.
Если последним дочерним элементом является EditText
, я ожидаю, что ScrollView
прокрутит, сделав EditText
видимым через программную клавиатуру. Но это заканчивается на этом https://imgur.com/GwOtLIq
Вид ожидаемого поведения может быть достигнут с использованием layout_marginBottom
вместо paddingBottom
, но в этом случае, очевидно, я не вижу своего контента за Button
. Снимок экрана https://imgur.com/oSC24qV
Есть ли способ заставить ScrollView
уважать его отступы с точки зрения избегания клавиатуры?
ОБНОВЛЕНИЕ: полный XML-код здесь https://pastebin.com/P8n0aZ2i