我有一个TextView
固定宽度如下:防止Word断
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="12sp"
tools:text="Health Department"
android:layout_marginTop="4dp"
android:maxLines="2"
/>
...但它看起来像:
|Health Dep-|
| artment |
...虽然我希望它是:
| Health |
|Department|
我可以用什么XML属性来做到这一点?
是否保证这两个单词每次都会在不同的行上?如果答案是肯定的,那么你可以在你的字符串中使用“换行符”。把它写成像这样'tool:text =“Health \ nDepartment”' – androidtitan
TextView的宽度取决于屏幕密度。如果没有好的解决方案,这可能是一个很好的解决方法。谢谢你的提示! – Asym