【发布时间】:2021-11-01 16:35:14
【问题描述】:
当我点击 3 个编辑文本中的 1 个时,我的键盘出现并且视图向上滚动一点。但是我的布局应该一直向上移动。我的xml文件:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/scrollView"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar"
app:layout_constraintVertical_bias="0.01999998">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="126dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding_default"
android:padding="@dimen/padding_small"
android:paddingHorizontal="@dimen/padding_default"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="16dp" />
<EditText
android:id="@+id/instructionsEditText"
android:layout_width="match_parent"
android:layout_height="600dp"
android:layout_margin="@dimen/padding_default"
android:gravity="top|start"
android:padding="@dimen/padding_small"
android:paddingHorizontal="@dimen/padding_default"
app:layout_constraintTop_toBottomOf="@+id/amountPersonsEditText" />
<EditText
android:id="@+id/notesEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/padding_default"
android:padding="@dimen/padding_small"
android:paddingHorizontal="@dimen/padding_default"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/instructionsEditText"
tools:layout_editor_absoluteX="16dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<android.widget.Button
android:id="@+id/saveInstructionsButton"
style="@style/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/padding_default"
android:gravity="center"
android:imeOptions="actionDone"
android:text="@string/instructions_button_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
我的机器人清单:
<activity
android:name=".ui.instructions.InstructionsActivity"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait" />
我也试过这个:
fun ScrollView.moveToTop() {
this.isFocusableInTouchMode = true
this.fullScroll(View.FOCUS_DOWN)
this.smoothScrollTo(0, bottom)
}
但是按钮在滚动视图之外并且按钮底部应该在键盘的顶部。
开始:
实际:
预期:
【问题讨论】:
-
我无法正确了解您,请您详细说明您的担忧
标签: android android-constraintlayout