Android TextView對齊的兩種方法
Android TextView對齊的兩種方法
在寫Android布局文件時, 經(jīng)常碰到如下圖的TextView左右對齊的情況, 即姓名和手機(jī)號碼縱向?qū)R。、

第一種方法: 在姓和名之間加空格, 但是如果用鍵盤的空格會在一些機(jī)型上對齊、一些機(jī)型上不對齊。
\u3000是全角空格; \u0020是半角空格,效果跟在英文輸入法下直接敲鍵盤空格一樣。 這里要用全角空格, 占位一個漢字。
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="姓\u3000\u3000名" android:textColor="#6e6e6e" android:textSize="13dp" />
第二種方法: 比較low。 用3個TextView, 第一個是“姓”、第二個是invisible(利用不顯示但占位的特性)的2個漢字如“姓名”, 第三個是“名”。
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="姓"
android:textColor="#6e6e6e"
android:textSize="13dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="姓名"
android:visibility="invisible"
android:textColor="#6e6e6e"
android:textSize="13dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="名"
android:textColor="#6e6e6e"
android:textSize="13dp" />
以上就是關(guān)于Android TextView 文本對齊的方法詳解,如有疑問還請大家留言,或者到本站社區(qū)交流,共同進(jìn)步,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
Android實現(xiàn)QQ手機(jī)管家懸浮小火箭效果
這篇文章主要介紹了Android實現(xiàn)QQ手機(jī)管家懸浮小火箭效果,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-05-05
Android實現(xiàn)GridView中ImageView動態(tài)變換的方法
這篇文章主要介紹了Android實現(xiàn)GridView中ImageView動態(tài)變換的方法,以實例形式較為詳細(xì)的分析了GridView中ImageView動態(tài)變換的頁面布局及功能實現(xiàn)相關(guān)技巧,需要的朋友可以參考下2015-10-10
Android之內(nèi)置和外置sdcard路徑顯示并且寫入數(shù)據(jù)的方法
今天小編就為大家分享一篇Android之內(nèi)置和外置sdcard路徑顯示并且寫入數(shù)據(jù)的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-08-08
Android TextWatcher三個回調(diào)以及監(jiān)聽EditText的輸入案例詳解
這篇文章主要介紹了Android TextWatcher三個回調(diào)以及監(jiān)聽EditText的輸入案例詳解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-08-08

