create shape xml file in drawable folder in android studio

66,706

Solution 1

follow these steps

  1. create a drawable folder in res directory.(if not present)

  2. right click on drawable folder> New > Drawable resource file

  3. Give your file a name and change the root element to shape. (its selector by default)

now you are good to go.

Solution 2

I was confused by the post from Anirudh when he said to change the root element to shape. But here is full demo.

Basically, the shape element is not provided by drawable resource file list by default. So just create one and then change the root xml element to shape, manually.

enter image description here

Share:
66,706

Related videos on Youtube

Abhishek Deshpande
Author by

Abhishek Deshpande

Updated on September 03, 2020

Comments

  • Abhishek Deshpande
    Abhishek Deshpande almost 4 years

    I am using Android studio 1.2.2 and need to know how to create a new shape file in drawable folder. I have already done the same in Eclipse but unable to do so in the android studio 1.2.2

  • Abhishek Deshpande
    Abhishek Deshpande almost 9 years
    Thank you.. It is so much easier in Eclipse ADT where the root tag is displayed in a list for selection
  • Anirudh Sharma
    Anirudh Sharma almost 9 years
    Yes.But it's autocomplete in android studio so have to type only sh and it will appear :) .Do accept the answer if it helps.
  • Janaka R Rajapaksha
    Janaka R Rajapaksha about 8 years
    In android studio, this is generating a layout xml file in layout folder. even can't move to drawable folder. So this is not an answer for this question.
  • andrewoodleyjr
    andrewoodleyjr almost 6 years
    think you meant New -> Drawable Resource File
  • Stack Overflow
    Stack Overflow almost 5 years
    this is for creating layout file, not shape file.

Related