android - 允许嵌套滚动同时允许编辑文本稍微扩展(xml)
问题描述
我想要的是能够拥有一个EditText
可以从 5 行扩展到 10 行文本的内容。当它达到 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"
推荐阅读
- c# - 在 c# 中发布到网页时,所需的防伪 cookie 不存在
- java - 如何在 Java 中声明和创建包含 Double 类型值的 3 行 x 5 列矩阵?
- python-3.x - 仅当用户发布新推文时,Tweepy 才会返回特定屏幕名称的推文
- angular - 角度路由器:使用数组作为参数
- python - 如何在使用 Python 的大文件上更快地执行名称实体识别
- java - xsd xsi:jsonschema 中的类型支持
- linux - 如何在异常时检索寄存器值?
- python - ValueError: int() 以 10 为底的无效文字:'' *Codewars
- javascript - 如何从 Typescript 中的函数参数中删除一些类型检查?
- python - 类型错误:参数 od type 'int' 在文件上不可迭代“
",第 31 行,在