防止TextView包装在父级中 [英] Prevent TextView from wrapping in parent

查看:80
本文介绍了防止TextView包装在父级中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何防止TextView或任何视觉对象包装到屏幕上,而是将它们从侧面切掉?是否有一些XML属性或代码可以执行此操作,或者是否不可能从屏幕上溢出任何内容?

How do I prevent a TextView, or any visual object, from wrapping to the screen and instead have them chopped off the sides? Is there some XML attribute or code to do this or is it impossible to have anything overflow from the screen?

例如,您有以下内容:

但是你真的想要这个:

有什么想法吗?

推荐答案

签出android:maxLines="1",如果要添加结尾...,还添加android:ellipsize="end"

check out android:maxLines="1" and if you want to add ending ... add also android:ellipsize="end"

<TextView
   android:id="@+id/name"
   android:text="i want this to crop not wrap"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:maxLines="1"
   android:ellipsize="end" />

android:singleLine="true"在API中已弃用 3级.

这篇关于防止TextView包装在父级中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆