0

I am building an app with backwards compatibility so I have to use a preferences activity instead of a preferences fragment. Everything works great but i'm struggling with some theme issues.

I use the following in my SettingsActivity.Java

//Create the settings toolbar LinearLayout root = (LinearLayout)findViewById(android.R.id.list).getParent().getParent().getParent(); Toolbar bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false); bar.setTitleTextColor(getResources().getColor(R.color.textColorPrimary)); root.addView(bar, 0); // insert at top bar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } });

to create and display a custom toolbar within my settings activity. I then have a settings_toolbar.xml:

<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
app:theme="@style/AppTheme.Dark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:navigationIcon="?attr/homeAsUpIndicator"
app:title="@string/action_settings"
/>

and a settings.xml file:

    <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory
        android:title="@string/pref_cat_app"
        android:key="pref_key_storage_settings">
        <ListPreference
            android:title="@string/pref_default_title"
            android:summary="@string/pref_default_prompt"
            android:key="defaultProvider"
            android:defaultValue="1"
            android:entries="@array/providerNames"
            android:entryValues="@array/providerValues" />
    </PreferenceCategory>
</PreferenceScreen>

which displays this...

Screenshot

Question is Why is the arrow black? I cannot seem to change the color of it no matter how I alter my themes. I can make all of the bar text and arrow white by changing my primary text color, but my app background is white so options text will be white also and not show up.

Justin
  • 1
  • 3
  • 1
    The optimal solution is to use PreferenceFragmentCompat, however it sounds like that is not an option for you. Have a look here to solve your specific issue: http://stackoverflow.com/questions/26564400/creating-a-preference-screen-with-support-v21-toolbar – Daniel Nugent Sep 01 '16 at 23:18
  • This answer is the one that uses PreferenceActivity: http://stackoverflow.com/a/27455330/4409409 – Daniel Nugent Sep 01 '16 at 23:19
  • Thank you, I am trying to comb through that and figure out how they solved it – Justin Sep 03 '16 at 02:26

0 Answers0