Android XML屬性比較多,全部記住不太現實,用的時候查文檔是一條途徑。如何迅速找到所需的XML屬性?
Android包下面android.R.styleable 類包含下面所有組件相關的XML屬性。
如:
public static final int[] LinearLayout_Layout
Since: API
Level
Attributes that can be used with a LinearLayout_Layout.
Includes the following attributes:
Attribute | Description |
---|---|
|
Standard gravity constant that a child can supply to its parent. |
|
Specifies the basic height of the view. |
|
|
|
Specifies the basic width of the view. |
值得一提的是:android:layout_gravity屬性在TextView裏面也能用。如設置TextView居中就需要這樣:
android:layout_gravity="center_horizontal'.
可是TextView並沒有繼承android.widget.LinearLayout.LayoutParams。
這說明他們之間的屬性是通用的。