Android的复选框preference标题颜色 [英] Android CheckBoxPreference title color
问题描述
我正在使用本回答。
但是,而不是设置的的android:文字颜色的为文本视图我使用
But instead of setting the android:textColor for the Text View i use
风格=?background_text_color_theme
style="?background_text_color_theme"
有根据不同的应用(白色文本颜色的黑色主题,反之亦然)的主题设置文本颜色。这在所有其他地方,除了复选框preference。
which has to set the text color depending on the theme of the application ( white text color for black theme and vice versa). This works in all other places except for 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" />
下面是我的style.xml:
Here is my 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>
的themes.xml:
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>
但文字颜色似乎没有根据样式进行设定。谁能告诉我为什么会发生?
But the text color does not seem to be set according to the style. Can anyone tell me why is it happening?
感谢你。
推荐答案
下面是我在做的情况下一些it..Just人们需要它的未来。
Here is how I did it..Just in case some one needs it in the future.
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);
}
}
和在preference XML使用的复选框preference:
And in the preference xml use this for the checkbox preference:
<packagename.CheckBoxPreferenceClass
android:key="@string/imp"
android:title="@string/title"/>
这篇关于Android的复选框preference标题颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!