android - 如何使 EditText 在 X 行后自动滚动
问题描述
我已经找到了很多关于如何制作可滚动 EditText 的答案,但没有人提到如何在 X 行后使文本滚动。在我的应用程序中,我需要在 5 行后自行滚动文本,否则文本会与下面的图标混淆。到目前为止,我一直在限制 maxLength 以避免这种情况,但我需要能够编写更多字符而不用担心它们与图标混淆。
<EditText
android:id="@+id/resultText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:textColorHint="@color/white"
android:textColor="@color/colorPrimaryDark"
android:textIsSelectable="true"
android:gravity="top"
android:fontFamily="sans-serif"
android:textSize="25dp"
android:textStyle="normal"
android:ems="30"
android:maxLength="180"
android:hint="Input here..."
android:textAlignment="center"
android:focusable="true"
android:focusableInTouchMode="true"
android:inputType="textMultiLine"
android:overScrollMode="always"
android:scrollbarStyle="insideInset"/>
解决方案
原来我正在寻找的是:
android:lines="5"
推荐阅读
- python - pygame操纵杆轴和按钮在virtualbox中的ubuntu linux中不断返回0
- spring - 如何在一个会话工厂中连接两个数据源?
- reactjs - 我的反应应用程序在每次渲染时读取 Firestore,如何减少读取并节省带宽?
- android - Android:更改选定的菜单项
- javascript - 如何通过参数过滤事件
- xml - 为什么 XInclude 转义 < 和 > 作为 XML/HTML 字符实体,< 和 >?
- python - Jupyter Notebook 中没有名为“pymysql”的模块错误
- python - 将一个值与列表一起传递给python中的地图
- python - Keras TensorFlow Hub:简单的 ELMO 网络入门
- c# - 如何在没有“另存为”对话框的情况下从 ASP.NET 下载带有响应对象的文件?