我有带有 ScorllView 和 Button 的 ConstraintLayout(连接到屏幕底部。当我在 ScrollView 内编辑 EditText 输入时。然后出现的键盘正在向上移动我的 ScrollView 内容(所需的行为,所以我可以滚动到它的末尾)但是它还按下按钮(不良行为)。
我想我可以改变 windowAdjustMode,也许我可以检测到键盘显示然后隐藏这个按钮?但这两种解决方案并不完美。
XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/submitButton"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="0dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText /> goes here
</android.support.constraint.ConstraintLayout>
</ScrollView>
<Button
android:id="@+id/submitButton"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_margin="0dp"
android:text="@string/wizard_singup_step_submit_button"
style="@style/FormSubmitButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</android.support.constraint.ConstraintLayout>