【发布时间】:2022-01-24 06:45:46
【问题描述】:
我的布局文件的结构:协调器布局 - NestedScrollView - 协调器布局 - 我希望能够滚动的对象
带有 TextInputEditText 的 TextInputLayout 位于屏幕底部,填充后会超出屏幕范围。当我折叠键盘时,它仍然无法滚动。
注意:我不想将 maxLines 设置为 Edittext 并使其自身可滚动。我希望它与其他元素一起滚动。
但是,例如,如果我将 TextView 放在屏幕底部并且它不适合,则页面是可滚动的。有什么想法吗?
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--other items i want to scroll-->
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/descriptionLayout"
android:layout_width="348dp"
android:layout_height="200dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="545dp"
android:ems="16"
android:fontFamily="@font/montserrat"
android:hint="Add image description (optional)"
android:inputType="textMultiLine|textAutoCorrect"
app:counterEnabled="true"
app:counterMaxLength="256"
app:boxBackgroundColor="@color/white"
app:srcCompat="@drawable/ic_round_cloud_upload_24"
android:textColor="#68B2A0"
android:textColorHint="#68B2A0"
app:hintTextColor="#68B2A0"
app:layout_anchor="@id/titleLayout"
app:boxStrokeErrorColor="#F75010"
app:boxStrokeColor="#68B2A0"
app:boxStrokeWidth="2dp"
app:errorIconTint="@color/error"
app:errorTextColor="@color/error"
app:layout_anchorGravity="center|bottom"
app:counterOverflowTextColor="@color/error"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:counterTextColor="@color/main_green"
>
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/descriptionTxt"
android:ems="16"
android:textSize="18sp"
android:textColor="#68B2A0"
android:fontFamily="@font/montserrat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxLines="7"
/>
</com.google.android.material.textfield.TextInputLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.core.widget.NestedScrollView>
<!--bottom app bar-->
</androidx.coordinatorlayout.widget.CoordinatorLayout>
【问题讨论】:
标签: android android-layout android-xml android-textinputlayout android-nestedscrollview