我想更改我的首选项类别的颜色,并将默认水平线更改为蓝色。这可能吗?
我尝试使用以下内容设置首选项设置的主题:
<style name="myPreferenceTheme" parent="@style/AppBaseTheme">
<item name="android:textColor">@color/blue</item>
</style>
但我得到以下输出:
我的首选项.xml 如下所示:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory
android:title="ACCOUNT" >
<Preference
android:key="googleAccount"
android:summary=""
android:title="Google Account" >
</Preference>
<Preference
android:key="signoutmenu"
android:summary=""
android:title="Sign out" >
</Preference>
</PreferenceScreen>
有人可以帮我解决这个问题,如上面的屏幕截图所示吗?
谢谢!
最佳答案
您可以创建自定义 PreferenceCategory 并更改“onBindView”方法上的标题颜色(在示例中,类别标题颜色更改为红色)。
public class MyPreferenceCategory extends PreferenceCategory {
public MyPreferenceCategory(Context context) {
super(context);
}
public MyPreferenceCategory(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyPreferenceCategory(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
TextView titleView = (TextView) view.findViewById(android.R.id.title);
titleView.setTextColor(Color.RED);
}
}
This link has the original solution from where I got this answer
关于android - 更改 Android 中首选项类别的文本颜色和水平颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25771247/