在Android自定义视图中调用obtainStyledAttributes()的正确方法是什么

时间:2017-06-13 01:06:57

标签: android android-custom-view

之间有什么区别
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CustomView, 0, 0);

TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomView, defStyleAttr, 0);

1 个答案:

答案 0 :(得分:1)

" defStyleAttr"是 当前主题中的一个属性,它包含对为TypedArray提供默认值的样式资源的引用。可以为0以查找默认值。