最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - How to scroll a TextInputEditText inside a ScrollViewNestedScrollView - Stack Overflow

programmeradmin9浏览0评论

I'm trying to make a TextInputEditText with maxLines = 10 be scollable in a way that when it's done scrolling, the parent should scroll but I can't get it to work.

The TextInputEditText behaves as if it didn't have anything to scroll. Is this possible to accomplish this?

If I want to scroll the text, I need to click on it first and then drag the handle which is very annoying and bad UX.

Here's what I have:

<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android=";
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="16dp">

        <com.google.android.material.textfield.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="top|start"
                android:inputType="textMultiLine"
                android:maxLines="10"
                android:overScrollMode="always"
                android:scrollbars="vertical" />

        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.textfield.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp">

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="top|start"
                android:inputType="textMultiLine"
                android:maxLines="10"
                android:overScrollMode="always"
                android:scrollbars="vertical" />

        </com.google.android.material.textfield.TextInputLayout>
    </LinearLayout>

</androidx.core.widget.NestedScrollView>
发布评论

评论列表(0)

  1. 暂无评论