【发布时间】:2018-12-21 03:50:06
【问题描述】:
我在 Android 中有一个自定义视图,并希望加载由 attrs 和 TypedArray 在自定义视图上设置的所有属性。例如,我在 xml 布局中定义了一个背景色属性,但无法在构造函数中加载它。
我尝试了但没有成功。
// To be done, get the background color from the attributes.
TypedArray l_typedArray = this.getContext().obtainStyledAttributes(attrs,?? , 0);
// not working Color backColor = l_typedArray.getColor()
【问题讨论】:
-
您能否更具体地了解“不工作”?是抛出异常、返回null等吗?
-
我找到了我的问题的答案。
标签: android typedarray