在 Android 多行 TextView 中禁用自动换行
我正在开发带有高级滑动功能的月视图(需要加载当前、下一个和上一个视图,以允许每个视图粘在您的手指上),这意味着我有很多视图,这导致事情有点慢。
| | #<-- screen bounderies
' previous ' current ' next ' #<-- three months loaded
' previous ' current ' next ' #<-- three months when the user drags their finger
因此,我想在单个 TextView 中表示多个事件。当用户点击月视图(小屏幕)上的某一天时,它将打开当天的日视图。
在月视图中的每一天(通常一天的宽度为屏幕宽度的七分之一,垂直方向略小于七分之一),我想避免这种情况
| 31|
|10a: |
| Testi|
|ng |
|11a: |
相反,我想
| 31|
|10a: |
| Testi|
|11a: |
| Anoth|
注意 ng
被切断而不是换行到下一行。这就是我正在寻找的。
I am working on a Month View with an advanced swipe (requires current, next and previous to be loaded to allow each view to stick to your finger) which means I have many views which causes things to be a little bit slow.
| | #<-- screen bounderies
' previous ' current ' next ' #<-- three months loaded
' previous ' current ' next ' #<-- three months when the user drags their finger
Because of this I want to represent multiple events in a single TextView. When the user taps one of the days on the Month View (small screen), it will open the day view for that day.
On each day in the month view (typically a single day gets one seventh of the width of the screen and a little less than one seventh vertically) I would like to avoid this
| 31|
|10a: |
| Testi|
|ng |
|11a: |
Instead I want
| 31|
|10a: |
| Testi|
|11a: |
| Anoth|
Notice that the ng
is cut off instead of wrapping to the next line. This is what I am looking for.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 Java 中:
理论上, android:scrollHorizontally 应该在 XML 中执行相同的操作,但是 android 中存在一个错误,导致它无法工作。
In Java:
In theory, android:scrollHorizontally should do the same in XML, but there is a bug in android that stops it working.
android:singleLine
-----这是用于 xmlsetTransformationMethod(TransformationMethod)
-----这是用于 java我不确定这是否有效,但当我希望 TextView 不包含在 ListView 中时,它对我有用
android:singleLine
-----this is for xmlsetTransformationMethod(TransformationMethod)
-----this is for javaI'm not sure if this will work, but it worked for me when I wanted my TextView not to wrap in my ListView
目前 XML 的最佳答案是
因为 android:singleLine 现已贬值
Currently the best answer for XML is
Because android:singleLine is now depreciated
java 代码中
在 XML 文件中的
就可以解决这个问题。
in java code
in XML file
does the trick.