My problem is a weird one (I think).
Using AppCompat my references to ?attr/colorPrimary are not working.
colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">@color/primary_material_dark</color>
<color name="colorPrimaryDark">@color/primary_dark_material_dark</color>
<color name="test">#ff2800</color>
</resources>
styles.xml:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:colorPrimary">@color/primary_material_dark</item>
<item name="android:colorPrimaryDark">@color/primary_dark_material_dark</item>
</style>
</resources>
activity_main.xml:
<LinearLayout 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"
android:orientation="vertical"
tools:context=".MainActivity"
android:background="?attr/colorPrimary">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
/>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="COLORCLOR"
android:background="?attr/colorPrimary"/>
</LinearLayout>
</LinearLayout>
Heres what it looks like:
But everything seems to work fine when I replace the ?attr/colorPrimary references with actual color refrences. Really confused about this, tried removing the theme and popupTheme attributes from toolbar, still didn't work.
PS. ?attr/colorPrimaryDark works just fine