ckd*_*ckd 0 checkbox android textcolor preferencescreen
我正在使用此答案中的代码.
但不是为我使用的文本视图设置android:textColor
风格= "?background_text_color_theme"
必须根据应用程序的主题设置文本颜色(黑色主题的白色文本颜色,反之亦然).这适用于除CheckBoxPreference之外的所有其他地方.
我对链接所做的更改:
<TextView android:id="@+android:id/title"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee" android:fadingEdge="horizontal"
style="?background_text_color_theme" />
Run Code Online (Sandbox Code Playgroud)
这是我的style.xml:
<style name="background_text_color_theme_bl">
<item name="android:textColor">#ffffff</item>
</style>
<style name="background_text_color_theme_wh">
<item name="android:textColor">#000000</item>
</style>
Run Code Online (Sandbox Code Playgroud)
的themes.xml:
<style name="Theme.White" parent="@android:style/Theme.Holo.Light">
<item name="background_text_color_theme">@style/background_text_color_theme_wh</item>
</style>
<style name="Theme.Black" parent="@android:style/Theme.Holo">
<item name="background_text_color_theme">@style/background_text_color_theme_bl</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但文字颜色似乎没有根据风格设置.谁能告诉我为什么会这样?
谢谢.
我是这样做的.以防万一将来需要它.
public class CheckBoxPreferenceClass extends CheckBoxPreference {
public CheckBoxPreferenceClass(Context context) {
super(context);
}
public CheckBoxPreferenceClass(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CheckBoxPreferenceClass(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
TextView title = (TextView) view.findViewById(android.R.id.title);
title.setTextColor(Color.BLACK);
}
}
Run Code Online (Sandbox Code Playgroud)
在首选项xml中使用它作为复选框首选项:
<packagename.CheckBoxPreferenceClass
android:key="@string/imp"
android:title="@string/title"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1778 次 |
| 最近记录: |