【发布时间】:2015-12-02 16:25:49
【问题描述】:
在 AppCompact 中,我们将 colorPrimary、colorPrimaryDark、colorAccent、textColorPrimary 等属性用于应用主题。
我想知道我们能否在片段或视图组中覆盖或将这些颜色更改为不同的颜色。比如,我们可以只为 NavigationView 更改这些颜色,还是只为 Fragment 中的 ExpandableListView 更改这些颜色。
编辑:
我尝试用不同的样式覆盖,但它不是覆盖
<style name="DarkText" parent="AppTheme">
<item name="android:textColorPrimary">@color/black</item>
<item name="android:textColorSecondary">@color/black</item>
</style>
<ExpandableListView
android:layout_height="match_parent"
android:theme="@style/DarkText"
android:groupIndicator="@android:color/transparent"
android:layout_width="match_parent"/>
适配器中的我的 ChildVeiw:
final String childText = (String) getChild(groupPosition, childPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_item, null);
}
TextView txtListChild = (TextView) convertView
.findViewById(R.id.lblListItem);
txtListChild.setText(childText);
请注意:我不想在我的 R.layout.list_item 中使用 txtListChild.setTextColor 或 android:textColor="@color/black" 更改文本颜色
【问题讨论】:
标签: android android-fragments android-appcompat android-theme