我想要的是能够拥有一个可以从5到10行文本扩展的EditText
。当它达到10行时,它会以嵌套的方式开始滚动。即,当达到编辑文本滚动的限制时,则可以滚动外部页面视图。到目前为止我尝试的是这个,但它不允许嵌套滚动:
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/edit_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="10"
android:background="@android:color/transparent"
android:gravity="top"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:textSize="15sp"
tools:text="Some description \n\n\n\n\n asdf \n asdf \n \n adsf \n asdf \n asdf \n asdf \n asfd " />
</androidx.core.widget.NestedScrollView>
但是,如果我在NesteScrollView
上设置特定的布局高度,它确实有效,但是那样就不会允许EditText
扩展。
也。我不想为此使用代码。我知道它可能会覆盖触摸事件等,但我正在寻找一种更清洁的方法。
尝试允许EditText
成为滚动容器,并确保它通知其父NestedScrollView:
android:isScrollContainer="true"
android:nestedScrollingEnabled="true"