26

When I create a new project with API14 as minimum, then there is no values-21 or values-22 folder in my project. I don't see any styles.XML anywhere, so how should I put in XML code for just Lollipop?

I use Android Studio 1.0.1, and I have SDK 21, 21.1.1, 24.0.2 installed.

bjiang
  • 6,068
  • 2
  • 22
  • 35
DMT82
  • 871
  • 2
  • 14
  • 32

3 Answers3

68

Updated: Since API 22 has been released. API 23 is the same idea.

Right click the RES folder

enter image description here

Then type values-v22 as the directory name and choose xml as the resource type.

enter image description here

If you do NOT see the values-v22 show up, click the Project pulldown at the top of the screen like so. e.g. Change from Android to Project

enter image description here

Now right click styles.xml in the values folder and choose copy

enter image description here

Now right click the values-v22 folder and click paste.

enter image description here

You should see this popup

enter image description here

Click ok

At this point you should be good to go.

bjiang
  • 6,068
  • 2
  • 22
  • 35
  • 1
    Thanks bjiang. @color/primary_material_dark dont have any problem in styles.xml in v21 folder while in the regular styles it says that I have min api14, so its correct. – DMT82 Dec 18 '14 at 19:00
  • @bjiang, i get Cannot resolve symbol 'android:Theme.Material.NoActionBar' in res/values-v21/styles.xml, and in plz help – Pankaj Nimgade Mar 05 '15 at 07:52
  • 1
    @PankajNimgade I think that because you lost `themes_material.xml` for some reason, you can get it from [here](https://gist.github.com/jbj88817/b0a3f750e3fe705a8a1a) and create a `xml file` named `themes_material.xml`, put the `file under the folder` of `sdk/platforms/android-21/data/res/values/` – bjiang Mar 05 '15 at 17:19
  • @bjiang, I have this file "themes_material.xml" in respective directory. I really don't know what else to do. in styles.xml i can't write any resource which starts with "android:" – Pankaj Nimgade Mar 06 '15 at 05:00
2

It is just a bug! Anyway I find a way to get it back:

  1. Write anything in styles.xml that is related to new material theme example: <item name="android:colorPrimary">@color/colorPrimary</item>

  2. It will show you an error hover over it and press Alt+Enter.

  3. choose the first choice Override Resource in values-v21.

I know it isn't the best way to do that, but it works until anyone can find a better way.

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
humazed
  • 74,687
  • 32
  • 99
  • 138
0

Try to switch from Android to [![Project][1]][1] as shown below

enter image description here

zizutg
  • 1,070
  • 14
  • 20