Android 自定義屬性詳解

2021-07-16 23:55:55 字數 2278 閱讀 7392

android中自定義屬性的格式詳解

1. reference:參考某一資源id。

(1)屬性定義:

(2)屬性使用:

android:layout_width = "42dip"

android:layout_height = "42dip"

android:background = "@drawable/id"

/>

2. color:顏色值。

(1)屬性定義:

(2)屬性使用:

android:layout_width = "42dip"

android:layout_height = "42dip"

android:textcolor = "#00ff00"

/>

3. boolean:布林值。

(1)屬性定義:

(2)屬性使用:

android:layout_width = "42dip"

android:layout_height = "42dip"

android:focusable = "true"

/>

4. dimension:尺寸值。

(1)屬性定義:

(2)屬性使用:

android:layout_width = "42dip"

android:layout_height = "42dip"

/>

5. float:浮點值。

(1)屬性定義:

(2)屬性使用:

android:fromalpha = "1.0"

android:toalpha = "0.7"

/>

6. integer:整型值。

(1)屬性定義:

(2)屬性使用:

xmlns:android = "

" android:drawable = "@drawable/id" 

android:pivotx = "50%" 

android:pivoty = "50%" 

android:framescount = "12" 

android:frameduration = "100"

/>

7. string:字串。

(1)屬性定義:

(2)屬性使用:

android:layout_width = "fill_parent"

android:layout_height = "fill_parent"

android:apikey = "0jokq80od1jl9c6haja99ugxcris2cgjko_bc_g"

/>

8. fraction:百分數。

(1)屬性定義:

(2)屬性使用:

"android:interpolator = "@anim/動畫id"

android:fromdegrees = "0"

android:todegrees = "360"

android:pivotx = "200%"

android:pivoty = "300%"

android:duration = "5000"

android:repeatmode = "restart"

android:repeatcount = "infinite"

/>

9. enum:列舉值。

(1)屬性定義:

(2)屬性使用:

xmlns:android = "

"android:orientation = "vertical"

android:layout_width = "fill_parent"

android:layout_height = "fill_parent"

>

10. flag:位或運算。

(1)屬性定義:

(2)屬性使用:

android:name = ".styleandthemeactivity"

android:windowsoftinputmode = "stateunspecified | stateunchanged | statehidden">

注意:屬性定義時可以指定多種型別值。

(1)屬性定義:

(2)屬性使用:

android:layout_width = "42dip"

android:layout_height = "42dip"

android:background = "@drawable/id|#00ff00"

/>

Android自定義屬性,format詳解

1.reference 參考某一資源id。1 屬性定義 background format reference 2 屬性使用 android layout width 42dip android layout height 42dip android background drawable id 2...

Android自定義控制項屬性詳解

1.reference 參考某一資源id。1 屬性定義 background format reference 2 屬性使用 background drawable id 2.color 顏色值。1 屬性定義 textcolor format color 2 屬性使用 textcolor 00ff0...

android自定義控制項屬性詳解

1.reference 參考某一資源id。1 屬性定義 2 屬性使用 2.color 顏色值。1 屬性定義 2 屬性使用 3.boolean 布林值。1 屬性定義 2 屬性使用 4.dimension 尺寸值。1 屬性定義 2 屬性使用 5.float 浮點值。1 屬性定義 2 屬性使用 6.int...