| Constant | Value | Description |
|---|---|---|
fill_parent | -1 |
The view should be as big as its parent (minus padding). This constant is deprecated starting from API Level 8 and is replaced by match_parent. |
match_parent | -1 | The view should be as big as its parent (minus padding). Introduced in API Level 8. |
wrap_content | -2 | The view should be only big enough to enclose its content (plus padding). |
实质上layout 只存在了两种,一种是match_parent, 另一种是 wrap_content. fill_parent 已经被match_parent所取代
-----------------------textsize-------------------------------
http://developer.android.com/training/multiscreen/screendensities.html
Therefore, when specifying dimensions, always use either dp or sp units. A dp is
a density-independent pixel that corresponds to the physical size of a pixel at 160 dpi. An sp is the same base unit, but is scaled by the user's preferred text size (it’s a scale-independent
pixel), so you should use this measurement unit when defining text size (but never for layout sizes).
For example, when you specify spacing between two views, usedp rather than px:
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/clickme" android:layout_marginTop="20dp" />
When specifying text size, always use sp:
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="20sp" />dp可以在不同的分辨率下实现物理尺寸“差不多”的效果
sp主要处理文字的大小
本文详细介绍了Android中两种常见的布局方式:match_parent和wrap_content,并解释了它们的区别及应用场景。此外,还深入探讨了dp和sp单位的概念,强调了在不同情境下使用这两种单位的重要性。
1万+

被折叠的 条评论
为什么被折叠?



