我想禁止用户展开文本字段,如图所示。它应该看起来像“密码”字段,但是两者都允许使用空格键或返回键执行以下操作。
最佳答案
将您的all
内边距设置为2dp
之类的值,然后将maxLines
设置为不会与文本重叠的值。可能是 2
或者如果您只关心 1 行,则设置 singleLine=true
。
您的 TextView
的 XML 可能如下所示:
<TextView
android:layout_width="fill_parent"
android:layout_height="200dp"
android:text="Hello World"
android:id="@+id/txtSomeIdForTextView"
android:layout_alignParentTop="true"
android:layout_alignParentStart="false"
android:padding="2dp"
android:textSize="16dp" />
看看这篇文章来开始使用 UI,虽然旧但仍然很好: https://mobiforge.com/design-development/understanding-user-interface-android-part-1-layouts
关于java - 阻止用户输入扩展文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36633015/