0

自定义属性很棒,但是所有教程都提到了在您准备好 AttributeSet 参数的自定义视图中的用法。

我的 attrs.xml 的内容:

<declare-styleable name="StyledDialogs">
   <attr name="sdlDialogStyle" format="reference" />
</declare-styleable>

<declare-styleable name="DialogStyle">
   ...
</declare-styleable>

我正在努力如何在自定义视图之外的任何类中访问这些属性。

4

1 回答 1

2

几个小时后,我想出了一种可行的方法:

final TypedArray a = mContext.getTheme().obtainStyledAttributes(null, R.styleable.DialogStyle, R.attr.sdlDialogStyle, 0);
于 2013-06-27T19:00:38.720 回答