title: ?Attr/color for Android < API21
body: <p>My app has multiple themes that are applied based on user preference, the app works fine on Android API => 21 and crashes in lower versions, I would like to support API 19 and above thus need your help.</p>
  
  <p><strong>Attrs.xml</strong>
  Three Custom attributes are defined as below:       </p>
  
  <pre><code>&lt;resources&gt;
          &lt;declare-styleable name="da"&gt;
              &lt;attr name="backgroundcolor" format="reference"/&gt;
              &lt;attr name="titletextcolor" format="reference"/&gt;
              &lt;attr name="textcolor" format="reference"/&gt;
          &lt;/declare-styleable&gt;
      &lt;/resources&gt;
  </code></pre>
  
  <p><strong>Styles.xml</strong>
  Three Custom Themes that include the custom attributes are defined as below:</p>
  
  <pre><code>&lt;style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"&gt;
              &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt;
              &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt;
              &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt;
              &lt;item name="backgroundcolor"&gt;@color/colorWhite&lt;/item&gt;
              &lt;item name="titletextcolor"&gt;@color/colorPrimary&lt;/item&gt;
              &lt;item name="textcolor"&gt;@color/colorBlack&lt;/item&gt;
          &lt;/style&gt;
  
          &lt;style name="AppTheme1" parent="Theme.AppCompat.Light.DarkActionBar"&gt;
              &lt;item name="colorPrimary"&gt;@color/colorPrimary1&lt;/item&gt;
              &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark1&lt;/item&gt;
              &lt;item name="colorAccent"&gt;@color/colorAccent1&lt;/item&gt;
              &lt;item name="backgroundcolor"&gt;@color/colorWhite&lt;/item&gt;
              &lt;item name="titletextcolor"&gt;@color/colorPrimary1&lt;/item&gt;
              &lt;item name="textcolor"&gt;@color/colorBla`&lt;/item&gt;
          &lt;/style&gt;
  
          &lt;style name="AppTheme2" parent="Theme.AppCompat.Light.DarkActionBar"&gt;
              &lt;item name="colorPrimary"&gt;@color/colorPrimary2&lt;/item&gt;
              &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark2&lt;/item&gt;
              &lt;item name="colorAccent"&gt;@color/colorAccent2&lt;/item&gt;
              &lt;item name="backgroundcolor"&gt;@color/colorWhite&lt;/item&gt;
              &lt;item name="titletextcolor"&gt;@color/colorPrimary2&lt;/item&gt;
              &lt;item name="textcolor"&gt;@color/colorBlack&lt;/item&gt;
          &lt;/style&gt;
  </code></pre>
  
  <p><strong>activity_nav.xml</strong>
  The custom attributes are used in multiple layout similar to the example below: </p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      android:background="?attr/backgroundcolor"
      android:layoutDirection="rtl"
      tools:openDrawer="start"&gt;
  
      &lt;include
          layout="@layout/app_bar_nav"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
      &lt;android.support.design.widget.NavigationView
          android:id="@+id/nav_view"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:background="?attr/backgroundcolor"
          app:itemTextColor="?attr/colorPrimary"
          app:itemIconTint="?attr/colorPrimary"
  
          android:layout_gravity="start"
          android:fitsSystemWindows="true"
          app:headerLayout="@layout/nav_header_nav"
          app:menu="@menu/activity_nav_drawer" /&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p><strong>NavActivity.java</strong>
  User theme preference is called for onCreate as shown below:</p>
  
  <pre><code> public class NavActivity extends AppCompatActivity
          implements NavigationView.OnNavigationItemSelectedListener {
  
      SharedPreferences shared;
      ListView listView;
      ListViewAdapter adapter;
  
      ArrayList&lt;Model&gt; arrayList = new ArrayList&lt;Model&gt;();
      private int i;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          shared = getSharedPreferences("Setting", Context.MODE_PRIVATE);
          int myStyle = shared.getInt("myStyle",0);
          switch (myStyle){
              case 0:
                  this.setTheme(R.style.NoActionBar);
                  break;
              case 1:
                  this.setTheme(R.style.NoActionBar1);
                  break;
              case 2:
                  this.setTheme(R.style.NoActionBar2);
                  break;
              case 3:
                  this.setTheme(R.style.NoActionBar3);
                  break;
          }
          setContentView(R.layout.activity_nav);
  
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          String [] title = getResources().getStringArray(R.array.titels);
          String [] desc = getResources().getStringArray(R.array.desc);
          int icon = R.drawable.icon;
  
          ListView listView = findViewById(R.id.listView);
  
          for (i =0 ; i&lt;title.length; i++){
              Model modle = new Model(title[i],desc[i],icon);
              arrayList.add(modle);
          }
  
          adapter = new ListViewAdapter(this,arrayList);
          listView.setAdapter(adapter);
  
  
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                  this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
          drawer.addDrawerListener(toggle);
          toggle.syncState();
  
          NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
          navigationView.setNavigationItemSelectedListener(this);
      }
  }
  </code></pre>
  
  <p><strong>Error Log</strong><br>
  App works fine on versions =>21  and crashes in lower versions with the following error:       </p>
  
  <pre><code>  E/AndroidRuntime: FATAL EXCEPTION: main
          Process: www.alitkaan2.com, PID: 3098
          java.lang.RuntimeException: Unable to start activity ComponentInfo{www.alitkaan2.com/www.alitkaan2.com.NavActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class android.support.design.widget.NavigationView
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
              at android.app.ActivityThread.access$800(ActivityThread.java:135)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:136)
              at android.app.ActivityThread.main(ActivityThread.java:5017)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:515)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
              at dalvik.system.NativeStart.main(Native Method)
           Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class android.support.design.widget.NavigationView
              at android.view.LayoutInflater.createView(LayoutInflater.java:621)
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
              at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
              at www.alitkaan2.com.NavActivity.onCreate(NavActivity.java:52)
              at android.app.Activity.performCreate(Activity.java:5231)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
              at android.app.ActivityThread.access$800(ActivityThread.java:135) 
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
              at android.os.Handler.dispatchMessage(Handler.java:102) 
              at android.os.Looper.loop(Looper.java:136) 
              at android.app.ActivityThread.main(ActivityThread.java:5017) 
              at java.lang.reflect.Method.invokeNative(Native Method) 
              at java.lang.reflect.Method.invoke(Method.java:515) 
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
              at dalvik.system.NativeStart.main(Native Method) 
           Caused by: java.lang.reflect.InvocationTargetException
              at java.lang.reflect.Constructor.constructNative(Native Method)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
              at android.view.LayoutInflater.createView(LayoutInflater.java:595)
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697) 
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:756) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
              at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
              at www.alitkaan2.com.NavActivity.onCreate(NavActivity.java:52) 
              at android.app.Activity.performCreate(Activity.java:5231) 
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
              at android.app.ActivityThread.access$800(ActivityThread.java:135) 
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
              at android.os.Handler.dispatchMessage(Handler.java:102) 
              at android.os.Looper.loop(Looper.java:136) 
              at android.app.ActivityThread.main(ActivityThread.java:5017) 
              at java.lang.reflect.Method.invokeNative(Native Method) 
              at java.lang.reflect.Method.invoke(Method.java:515) 
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
              at dalvik.system.NativeStart.main(Native Method) 
           Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class &lt;unknown&gt;
              at android.view.LayoutInflater.createView(LayoutInflater.java:621)
              at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
              at android.view.LayoutInflater.onCreateView(LayoutInflater.java:670)
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
              at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:207)
              at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:281)
              at android.support.design.widget.NavigationView.&lt;init&gt;(NavigationView.java:193)
              at android.support.design.widget.NavigationView.&lt;init&gt;(NavigationView.java:104)
              at java.lang.reflect.Constructor.constructNative(Native Method) 
              at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
              at android.view.LayoutInflater.createView(LayoutInflater.java:595) 
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697) 
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:756) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
              at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
              at www.alitkaan2.com.NavActivity.onCreate(NavActivity.java:52) 
              at android.app.Activity.performCreate(Activity.java:5231) 
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
              at android.app.ActivityThread.access$800(ActivityThread.java:135) 
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
              at android.os.Handler.dispatchMessage(Handler.java:102) 
              at android.os.Looper.loop(Looper.java:136) 
              at android.app.ActivityThread.main(ActivityThread.java:5017) 
              at java.lang.reflect.Method.invokeNative(Native Method) 
              at java.lang.reflect.Method.invoke(Method.java:515) 
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
              at dalvik.system.NativeStart.main(Native Method) 
           Caused by: java.lang.reflect.InvocationTargetException
              at java.lang.reflect.Constructor.constructNative(Native Method)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
              at android.view.LayoutInflater.createView(LayoutInflater.java:595)
              at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
              at android.view.LayoutInflater.onCreateView(LayoutInflater.java:670) 
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:469) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
              at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:207) 
              at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:281) 
              at android.support.design.widget.NavigationView.&lt;init&gt;(NavigationView.java:193) 
              at android.support.design.widget.NavigationView.&lt;init&gt;(NavigationView.java:104) 
              at java.lang.reflect.Constructor.constructNative(Native Method) 
              at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
              at android.view.LayoutInflater.createView(LayoutInflater.java:595) 
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697) 
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:756) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
              at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
              at www.alitkaan2.com.NavActivity.onCreate(NavActivity.java:52) 
              at android.app.Activity.performCreate(Activity.java:5231) 
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
              at android.app.ActivityThread.access$800(ActivityThread.java:135) 
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
              at android.os.Handler.dispatchMessage(Handler.java:102) 
              at android.os.Looper.loop(Looper.java:136) 
              at android.app.ActivityThread.main(ActivityThread.java:5017) 
              at java.lang.reflect.Method.invokeNative(Native Method) 
              at java.lang.reflect.Method.invoke(Method.java:515) 
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
              at dalvik.system.NativeStart.main(Native Method) 
           Caused by: android.content.res.Resources$NotFoundException: File res/drawable/side_nav_bar.xml from drawable resource ID #0x7f08008f
              at android.content.res.Resources.loadDrawable(Resources.java:2101)
              at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
              at android.view.View.&lt;init&gt;(View.java:3554)
              at android.view.ViewGroup.&lt;init&gt;(ViewGroup.java:470)
              at android.widget.LinearLayout.&lt;init&gt;(LinearLayout.java:176)
              at android.widget.LinearLayout.&lt;init&gt;(LinearLayout.java:172)
              at java.lang.reflect.Constructor.constructNative(Native Method) 
              at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
              at android.view.LayoutInflater.createView(LayoutInflater.java:595) 
              at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
              at android.view.LayoutInflater.onCreateView(LayoutInflater.java:670) 
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:469) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
              at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:207) 
              at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:281) 
              at android.support.design.widget.NavigationView.&lt;init&gt;(NavigationView.java:193) 
              at android.support.design.widget.NavigationView.&lt;init&gt;(NavigationView.java:104) 
              at java.lang.reflect.Constructor.constructNative(Native Method) 
              at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
              at android.view.LayoutInflater.createView(LayoutInflater.java:595) 
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697) 
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:756) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
              at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
              at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
              at www.alitkaan2.com.NavActivity.onCreate(NavActivity.java:52) 
              at android.app.Activity.performCreate(Activity.java:5231) 
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
              at android.app.ActivityThread.access$800(ActivityThread.java:135) 
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
              at android.os.Handler.dispatchMessage(Handler.java:102) 
              at android.os.Looper.loop(Looper.java:136) 
              at android.app.ActivityThread.main(ActivityThread.java:5017) 
              at java.lang.reflect.Method.invokeNative(Native Method) 
              at java.lang.reflect.Method.invoke(Method.java:515) 
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
              at dalvik.system.NativeStart.main(Native Method) 
          Caused b
      Disconnected from the target VM, address: 'localhost:8628', transport: 'socket'
  </code></pre>
  
  <p><strong>I would like to support Android versions with API 19 and above thus need your help.</strong></p>