【发布时间】:2020-10-14 11:39:54
【问题描述】:
我在style.xml 文件中定义了一个主题。
<style name="ThemePurple" parent="AppTheme.NoActionBar">
<item name="colorPrimary">@color/colorPurple</item>
<item name="colorPrimaryDark">@color/colorPurpleDark</item>
<item name="colorAccent">@color/colorPurpleAccent</item>
</style>
我想将此主题的colorPrimary 用于recyclerView 中的textView。我试过这个:
int[] attrs = {android.R.attr.colorPrimary};
TypedArray typedArray = mContext.obtainStyledAttributes(R.style.ThemePurple, attrs);
holder.titleView.setTextColor(typedArray.getColor(0, Color.BLACK));
typedArray.recycle();
但这不起作用..
【问题讨论】:
标签: java android styles android-theme