比如在res/attrs中定義如下屬性:< declare-styleable name="MyView"> < attr name="textColor" format="color" />如何改變textColor的值。請教。
2 回答

www說
TA貢獻1775條經(jīng)驗 獲得超8個贊
三、在自定義組件中,可以如下獲得xml中定義的值: TypedArray a = context.obtainStyledAttributes

米脂
TA貢獻1836條經(jīng)驗 獲得超3個贊
#為此屬性的值如android:layout_height android:layout_widthandroid:background都可寫成如下形式<item name="所以可以直接在其他view的屬性中引用此style.自定義的屬性要經(jīng)過兩個步驟才可以使用..values目錄下創(chuàng)建一個attrs.
添加回答
舉報
0/150
提交
取消