为什么 PreferenceCategory 的标题和复选框颜色这么浅?我该如何更改它?

Why PreferenceCategory's title & checkBox color is so light & how can I change it?

我正在开发一个 material 设计应用程序并且我已经为设置选项声明了一个 xml 文件。我已成功完成此任务,但在 运行 并从菜单中打开 SettingsActivity 后,它显示如下:

这里的问题是 'Notification' 的标题和复选框的颜色很浅,很难看清。

这是 SettingsActivity.java 文件的代码:

public class SettingsActivity extends AppCompatActivity {

    Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);

        SpannableString s = new SpannableString("Settings");
        s.setSpan(new TypefaceSpan(this, "Roboto-Medium.ttf"), 0, s.length(),
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle(s);

        // Display the fragment as the main content.
        getFragmentManager().beginTransaction()
                .replace(R.id.fragment_container, new SettingsFragment())
                .commit();

    }

    public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {

        public static final String SHARE_APP_PREFERENCE_KEY = "pref_key_share_app";

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            // Load the preferences from an XML resource
            addPreferencesFromResource(R.xml.settings);

        }

        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
                                              String key) {
            if (key.equals(SHARE_APP_PREFERENCE_KEY)) {
                // do something
            }
        }

    }

}

这是 activity_settings.xml 文件的代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:context="com.xxx.abc.SettingsActivity">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        android:elevation="4dp"/>

    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_below="@id/toolbar"
        android:layout_height="match_parent"/>

</RelativeLayout>

这是 settings.xml 文件的代码:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory
        android:key="prefNotification"
        android:title="@string/prefNotification">
    <CheckBoxPreference
        android:id="@+id/prefNotifyCheckBox"
        android:dependency="prefNotification"
        android:key="prefNotify"
        android:summary="@string/pref_notify_summary"
        android:defaultValue="true"/>
    </PreferenceCategory>
</PreferenceScreen>

由于我是 Android 开发的新手,我无法弄清楚这里的问题。

请告诉我。

提前致谢。

默认情况下,

PreferenceFragment 使用应用主题 colorAccent 中存储的值来设置小部件和标题的样式。要解决它,请在 styles.xml 文件中创建自定义主题,并将 colorAccent 属性设置为替代颜色:

<style name="theme_name" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/another_color</item>
    <item name="colorAccent">@color/yet_another_color</item>
</style>

要将其应用于您的 PreferenceFragment,请在 PreferenceFragmentonCreate() 中调用 getActivity().setTheme(R.style.theme_name)