【发布时间】:2018-12-14 17:32:12
【问题描述】:
我有一个限制在父级底部的视图。我也有顶部的文本字段。当键盘出现时,它会将底部视图向上推,这将覆盖我的文本字段。
我将所有内容都放在滚动视图中,键盘应该覆盖底部视图,并且我应该能够滚动到底部以到达底部视图。
这是一个简单的例子。我手动增加了高度以更容易地重现问题。我其实有更多的意见,这只是为了演示。
请注意,fillViewPort 也已启用。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/edit_text_1"
android:layout_width="0dp"
android:layout_height="180dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<EditText
android:id="@+id/edit_text_2"
android:layout_width="0dp"
android:layout_height="180dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/edit_text_1" />
<View
android:id="@+id/bottom_view"
android:layout_width="0dp"
android:layout_height="160dp"
android:background="@color/grey_500"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
【问题讨论】:
标签: android scrollview android-softkeyboard android-constraintlayout