styles.xml.
? , ?
, ,
TypedArray a = context.obtainStyledAttributes(AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes)
(),
AttributeSet set = null;, , XML.
int[] attrs = R.styleable.MyWidget; , .
int defStyleAttr = myWidgetStyle;, , , MyWidget. XML res/values.
"myWidgetStyle" , Android .
defStyleRes = 0; , .
, , ,
Color color = a.getColor(R.styleable.MyWidget_background, R.color.my_default);
a.recycle();
- .
, android a.getColor R.styleable.MyWidget_background. , Android, , , XML MyWidget.
I expect that you can find the correct index by doing a TypedArray search for the required attribute, but that will be inefficient, and TypedArray looks like an unpleasant fixture for a solution. I would use a very long stick to stick it out!
Don
source
share