【发布时间】:2019-11-19 04:10:11
【问题描述】:
我有RelativeLayout -> ScrollView -> ConstraintLayout -> EditText..Button -> /Constraint -> /ScrollView -> /RelativeLayout 打开键盘时,它只推送 EditText,但 Button 隐藏在键盘下方。
我尝试了什么:android:windowSoftInputMode="adjustResize" / adjustPan /Nothig / StateHidden.... 拳头系统窗口 = 真 填充视口 = 真 将约束更改为相对布局后的 alignParentBottom NestedScrollView 而不是 ScrollView
没有任何作用。我在 Android 6 上测试。
<RelativeLayout 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:background="@color/white"
tools:context=".screens.news.leave.NewsDetailActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:paddingTop="@dimen/margin_large">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp">
........
<EditText
android:id="@+id/commentET"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/sendComment"
android:layout_marginStart="@dimen/margin_medium"
android:layout_marginTop="@dimen/margin_medium"
android:layout_marginEnd="@dimen/margin_medium"
android:fontFamily="@font/roboto_regular"
android:hint="Оставить комментарий"
android:textColor="#878787"
android:textSize="@dimen/textsize_large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/commentsRV" />
<Button
android:id="@+id/sendComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_medium"
android:layout_marginEnd="@dimen/margin_medium"
android:layout_marginBottom="16dp"
android:background="@drawable/button_selector"
android:text="Оставить комментарий"
android:textColor="@color/textWhite"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/commentET" />
...
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
如何在键盘上按下按钮? PS。放弃相对布局是不可能的,因为它里面有一些不能滚动的视图
【问题讨论】:
-
您是想隐藏键盘以查看按钮还是只是想将按钮移到键盘上方?
-
@HayesRoach,我正在尝试将按钮移动到键盘上方。