Constant | Value | Description |
---|---|---|
| -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 . |
| -1 | The view should be as big as its parent (minus padding). Introduced in API Level 8. |
| -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, use
dp
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主要处理文字的大小