當在相對佈局的環境中使用時,「基線」是指什麼?簡單的問題,可能,但文檔和谷歌提供沒有提示。RelativeLayout中的基線是什麼?
68
A
回答
104
術語baseline comes from typography。這是文字中的無形線條字母。
例如,假設您將兩個TextView
元素相鄰放置。你給第二個TextView
一個很大的填充(比如20dp)。如果將layout_alignBaseline
添加到第二個元素,則文本將「scoot up」以與第一個元素的基線對齊。來自這兩個元素的文本將顯示爲就像它們寫在同一條不可見的行上一樣。
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/text1"
android:text="aatlg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:text="joof"
android:background="#00ff00"
android:padding="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/text1"
android:layout_alignBaseline="@id/text1"
/>
</RelativeLayout>
19
這裏是一個可以解釋克里斯蒂安的回答視覺解釋:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/text1"
android:text="Lorem"
android:background="@android:color/holo_blue_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:text="Ipsum"
android:background="@android:color/holo_orange_light"
android:padding="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/text1"
<!-->>>>>>>--> android:layout_alignBaseline="@id/text1" />
</RelativeLayout>
此代碼將是這樣的:
現在,如果我刪除android:layout_alignBaseline
屬性,相同的佈局看起來像這樣:
有趣的是,觀察到對第二視圖的高度有影響(在第一種情況下,應用於視圖頂部的填充爲而不是)。
相關問題
- 1. RelativeLayout:基線對齊有什麼問題?
- 2. 什麼是基線的LinearLayout的Android
- 3. Clearcase UCM中完整基線和增量基線之間的區別是什麼?
- 4. 什麼是'this'在這裏執行relativelayout lyt = new relativelayout(this)
- 5. 什麼是UCM中的複合基線以及何時使用?
- 6. UCM中過時基線的影響是什麼?
- 7. 在ClearCase中刪除基線的語法是什麼?
- 8. 什麼是C++中「低級」多線程的基本示例?
- 9. 什麼是基礎*(*)()
- 10. RelativeLayout中的基線對齊無法用於RadioGroup
- 11. Android RelativeLayout線程
- 12. 什麼是在線
- 13. 什麼是線程?
- 14. 什麼是線程?
- 15. 基礎知識中的API是什麼?
- 16. OSGi中的基礎主題是什麼?
- 17. Java中的組件基準是什麼
- 18. 數據庫中的基數是什麼?
- 19. 我的路線是什麼?
- 20. GCD的主線是什麼?
- 21. 具體是什麼線的
- 22. 什麼是Java中的線程組?
- 23. javadumps中的線程ID是什麼?
- 24. 什麼是Rails中的路線
- 25. Lua中的多線模式是什麼?
- 26. 什麼是Perl中的雙下劃線?
- 27. actionscript函數中的線程是什麼?
- 28. 什麼是Java中的process_reaper線程?
- 29. 什麼是node_redis中的流水線?
- 30. 什麼是java中的線程同步?
添加說明圖片會很好 – htafoya
也默認爲true –