the application I am working on I have set the primary/dark/accent colors to the colors I desire and they appear in the correct locations (as expected). I have a preference activity that I am using though, and I was hoping that the color of the preferenceswitch
's that I am using would render in the accent color. Instead they are rendering in the material teal color. I was wondering is this default behavior with Lollipop, like in Kitkat it was the blue? I don't even reference the color which is #009688
anywhere in my code or my colors.xml
/ styles.xml
.
colors.xml
<resources>
<color name="primary">#00BCD4</color>
<color name="primary_dark">#0097A7</color>
<color name="accent">#FFD740</color>
</resources>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorAccent">@color/accent</item>
</style>
</resources>
Any Ideas? I'll provide any more info. I saw some stuff on here about creating custom stuff, but is that really necessary?
preferenceActivity.java
public class PreferenceActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PrefFrag prefFragment = new PrefFrag();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(android.R.id.content, prefFragment);
fragmentTransaction.commit();
}
}
When you use AppCompat
, you should use the non-prefixed versions of each attribute - this ensures that they are available on all API levels (unlike the android:
ones, which only work on API21+ for example):
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
</style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With