java – 如何更改PreferenceCategory / PreferenceScreen的文本颜色
作者:互联网
这里是:
的preferences.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory
android:key="@string/pref_basicsettings_key"
android:title="@string/pref_basicsettings_title" >
<CheckBoxPreference
android:defaultValue="@string/pref_test1_default"
android:key="@string/pref_test1_key"
android:summary="@string/pref_test1_dlg"
android:title="@string/pref_test1_title" />
<CheckBoxPreference
android:defaultValue="@string/pref_test2_default"
android:key="@string/pref_test2_key"
android:summary="@string/pref_test2_dlg"
android:title="@string/pref_test2_title" />
</PreferenceCategory>
</PreferenceScreen>
BasicSettingsActivity.java
public class BasicSettingsActivity extends PreferenceActivity {
public static final String TAG = BasicSettingsActivity.class
.getSimpleName();
/** Called when the activity is first created. */
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
prefs.registerOnSharedPreferenceChangeListener(mSharedPreferenceListener);
// add preference resource
addPreferencesFromResource(com.testapp.R.xml.basic_settings);
}
}
如何更改PreferenceCategory中的文本颜色?
最佳答案:
我添加了一种新风格:
<style name="PreferenceScreen" parent="Theme.AppCompat">
<item name="android:textColor">#ffffff</item>
<item name="android:textColorPrimary">#ffffff</item>
<item name="colorPrimary">#ff0000</item>
<item name="colorPrimaryDark">#ff0000</item>
<item name="colorAccent">#ff0000</item>
<item name="android:background">#CCCCCC</item>
</style>
并将其包含在活动中:
<activity android:name="com.smartipcamera.owlcam.ui.BasicSettingsActivity"
android:theme="@style/PreferenceScreen" >
</activity>
标签:java,android,layout,sharedpreferences,textcolor 来源: https://codeday.me/bug/20190516/1115360.html