打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
解决Android TextView超出屏幕宽度文字显示问题
xml文件中添加android:ellipsize="end"和android:layout_height="wrap_content"这两句话即可解决

代码如下:

<TextView android:id="@+id/aa"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:ellipsize="end"
   android:singleLine="true"
   />

如果你用的是EditText,解决方法一样,它有个函数专门解决这个问题,看了API您就恍然大悟了

publicvoid setEllipsize (TextUtils.TruncateAt ellipsis)

Causes words in the text that are longer than the view is wideto be ellipsized instead of broken in the middle. You may also wantto setSingleLine() orsetHorizontallyScrolling(boolean) to constrainthe text to a single line. Use null to turn offellipsizing.


本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Android:Layout_weight的深刻理解
EditText 和 TextView 的属性详解
Android 五大布局讲解与应用 – 码农网
Android之解决底部4个TextView占比例大小不一致问题
Android屏幕适配方案,直接填写设计图上的像素尺寸即可完成适配,最大限度解决适配问题
Android实现自定义带文字和图片的Button
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服