日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

xml属性定义

發布時間:2025/3/21 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 xml属性定义 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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

? ? 1)屬性定義:

<declare-styleable name="名稱"> ?

? ? <attr format="reference" name="background" /> ?

</declare-styleable> ?

?

?

? ? 2)屬性使用:

<ImageView ?

? ? android:layout_width="42dip" ?

? ? android:layout_height="42dip" ?

? ? android:background="@drawable/圖片ID" /> ?

?

?

2. color:顏色值。

? ? (1)屬性定義:

<declare-styleable name="名稱"> ?

? ? <attr format="color" name="textColor" /> ?

</declare-styleable> ?

?

?

? ? (2)屬性使用:

<TextView ?

? ? android:layout_width="42dip" ?

? ? android:layout_height="42dip" ?

? ? android:textColor="#00FF00" /> ?

?

?

3. boolean:布爾值。

? ? (1)屬性定義:

<declare-styleable name="名稱"> ?

? ? <attr format="boolean" name="focusable" /> ?

</declare-styleable> ?

?

?

? ? (2)屬性使用:

<Button ?

? ? android:layout_width="42dip" ?

? ? android:layout_height="42dip" ?

? ? android:focusable="true" /> ?

?

?

4. dimension:尺寸值。

? ? (1)屬性定義:

<declare-styleable name="名稱"> ?

? ? <attr format="dimension" name="layout_width" /> ?

</declare-styleable> ?

?

?

? ? (2)屬性使用:

<Button ?

? ? android:layout_width="42dip" ?

? ? android:layout_height="42dip" /> ?

?

?

5. float:浮點值。

? ? (1)屬性定義:

<declare-styleable name="AlphaAnimation"> ?

? ? <attr format="float" name="fromAlpha" /> ?

? ? <attr format="float" name="toAlpha" /> ?

</declare-styleable> ?

?

?

? ? (2)屬性使用:

<alpha ?

? ? android:fromAlpha="1.0" ?

? ? android:toAlpha="0.7" /> ?

?

?

6. integer:整型值。

? ? (1)屬性定義:

<declare-styleable name="AnimatedRotateDrawable"> ?

? ? <attr format="integer" name="frameDuration" /> ?

? ? <attr format="integer" name="framesCount" /> ?

</declare-styleable> ?

?

?

? ? (2)屬性使用:

<animated-rotate ?

? ? android:frameDuration="100" ?

? ? android:framesCount="12" ?

? ? /> ?

?

?

7. string:字符串。

? ? (1)屬性定義:

<declare-styleable name="MapView"> ?

? ? <attr format="string" name="apiKey" /> ?

</declare-styleable> ?

?

?

? ? (2)屬性使用:

<com.google.android.maps.MapView ?

? ? android:layout_width="fill_parent" ?

? ? android:layout_height="fill_parent" ?

? ? android:apiKey="0jOkQ80oD1JL9C6HAja99uGXCRiS2CGjKO_bc_g" /> ?

?

?

8. fraction:百分數。

? ? (1)屬性定義:

<declare-styleable name="RotateDrawable"> ?

? ? <attr format="fraction" name="pivotX" /> ?

? ? <attr format="fraction" name="pivotY" /> ?

</declare-styleable> ?

?

?

? ? (2)屬性使用:

<rotate ?

? ? android:pivotX="200%" ?

? ? android:pivotY="300%" ?

? ? /> ?

?

?

9. enum:枚舉值。

? ? (1)屬性定義:

<declare-styleable name="名稱"> ?

? ? <attr name="orientation"> ?

? ? ? ? <enum name="horizontal" value="0" /> ?

? ? ? ? <enum name="vertical" value="1" /> ?

? ? </attr> ?

</declare-styleable> ?

?

?

? ? (2)屬性使用:

<LinearLayout ?

? ? android:orientation="vertical" > ?

</LinearLayout> ?

?

?

10. flag:位或運算。

?? ? (1)屬性定義:

<declare-styleable name="名稱"> ?

? ? <attr name="windowSoftInputMode"> ?

? ? ? ? <flag name="stateUnspecified" value="0" /> ?

? ? ? ? <flag name="stateUnchanged" value="1" /> ?

? ? ? ? <flag name="stateHidden" value="2" /> ?

? ? ? ? <flag name="stateAlwaysHidden" value="3" /> ?

? ? ? ? <flag name="stateVisible" value="4" /> ?

? ? ? ? <flag name="stateAlwaysVisible" value="5" /> ?

? ? ? ? <flag name="adjustUnspecified" value="0x00" /> ?

? ? ? ? <flag name="adjustResize" value="0x10" /> ?

? ? ? ? <flag name="adjustPan" value="0x20" /> ?

? ? ? ? <flag name="adjustNothing" value="0x30" /> ?

? ? </attr> ?

</declare-styleable> ?

?

?

?? ? (2)屬性使用:

<activity ?

? ? android:windowSoftInputMode="stateUnspecified | stateUnchanged | stateHidden" > ?

</activity> ?

?

?

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

? ? (1)屬性定義:

<declare-styleable name="名稱"> ?

? ? <attr format="reference|color" name="background" /> ?

</declare-styleable> ?

?

?

? ? (2)屬性使用:

<ImageView ?

? ? android:layout_width="42dip" ?

? ? android:layout_height="42dip" ?

? ? android:background="@drawable/圖片ID|#00FF00" />?

轉載于:https://www.cnblogs.com/liulipeng/p/3916745.html

總結

以上是生活随笔為你收集整理的xml属性定义的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。