android maxlength 汉字,Android TextView maxWidth、maxLines、maxLength、maxEms
TextView maxWidth、maxLines、maxLength、maxEms 的區別面紗就此揭開!掌握它們的區別對實際開發蠻有用處。若您有遇到其它相關問題,很是歡迎在評論中留言,我和其余讀者小伙伴們將幫助解決并持續更新至此文,達到幫助更多人的目的。若感本文對您有所幫助請點個贊吧!android
maxWidth
限制當前view的寬度,若此時高度設置為wrap_content,文字長度超過view的寬度時會自動換行web
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#3E86A0"
android:textColor="#ffffff"
android:text="TextView_maxWidth"
android:maxWidth="50dp"/>
maxLines
不管文字總體須要幾行才可顯示,最終只顯示 N 行。通常配合ellipsize標簽使用,它可指定在尾部添加省略號svg
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#3E86A0"
android:textColor="#ffffff"
android:text="TextView_maxWidthTextView_maxWidthTextView_maxWidth"
android:ellipsize="end"
android:maxLines="1"/>
maxLength
限制可顯示字符數量,超出部分會被截斷,設置 ellipsize 也無效,字母或漢字每一個單位均記作1,測試
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#3E86A0"
android:textColor="#ffffff"
android:text="TextView_maxWidth"
android:ellipsize="end"
android:maxLength="5"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#3E86A0"
android:textColor="#ffffff"
android:text="測試這個標簽的做用"
android:ellipsize="end"
android:maxLength="5"/>
maxEms
單行最多可現實的字符數量,超出限制自動換行,漢字記作2個單位,字母記作1個單位code
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#3E86A0"
android:textColor="#ffffff"
android:text="TextView_maxWidth"
android:maxEms="5"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#3E86A0"
android:textColor="#ffffff"
android:text="測試這個標簽的做用"
android:maxLines="1" // 這里設置了行數限制,因此下圖中的文字被截取
android:maxEms="5"/>
若您有遇到其它相關問題,很是歡迎在評論中留言,我和其余讀者小伙伴們將幫助解決并持續更新至此文,達到幫助更多人的目的。若感本文對您有所幫助請點個贊吧!xml
總結
以上是生活随笔為你收集整理的android maxlength 汉字,Android TextView maxWidth、maxLines、maxLength、maxEms的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: pdf切割软件linux,linux下的
- 下一篇: GBase 8a 部署(8.6)