No resource found matching the given name 'android: Theme.Material'

After reading this answer , I made RecyclerView run it on Android 3.0+. But styles.xml in values-v21 is still values-v21 error.

Topic.

 <!-- inherit from the material theme --> <style name="AppTheme" parent="android:Theme.Material"> <!-- Main theme colors --> <!-- your app branding color (for the app bar) --> <item name="android:colorPrimary">#f00</item> <!-- darker variant of colorPrimary (for status bar, contextual app bars) --> <item name="android:colorPrimaryDark">#0f0</item> <!-- theme UI controls like checkboxes and text fields --> <item name="android:colorAccent">#00f</item> </style> 

Error.

Error: error getting the parent element for the element: a resource was not found that matches the given name 'android: Theme.Material'.

I need to support Android versions with Android 3.0.x (API level 11). <uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L" /> not a solution.

+5
source share
2 answers

android:Theme.Material is only supported from API level 21. You can see the error message in Android studio as shown below:

 android.Theme.Material requires API level 21(current min is 14) 
+2
source

If you use the support library, you can safely use these attributes, and they will work (as far as the OS allows):

 <style name="AppTheme" parent="@style/Theme.AppCompat.Light"> <item name="colorPrimary">...</item> </style> 

You can also use others:

  <item name="colorPrimaryDark">...</item> <item name="colorAccent">...</item> 
+1
source

Source: https://habr.com/ru/post/1201915/


All Articles