Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create shape xml file in drawable folder in android studio

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

like image 697
Abhishek Deshpande Avatar asked Jul 17 '15 04:07

Abhishek Deshpande


People also ask

Can I create a folder in drawable Android studio?

Simply go to project Explorer and change your View from Android to project from drop Down and you are good to go. There you can simply create folder like we do in Eclipse. And in android project view it is hidden but when you switch to project. You can create folder like drawable-hdpi,drawable-xhdpi .

What is shape in XML?

The Shape Drawable is an XML file that defines a geometric shape, including colors and gradients. This is used to create a complex shape that can then be attached as the background of a layout or a view on screen.


2 Answers

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.

like image 156
Anirudh Sharma Avatar answered Sep 30 '22 12:09

Anirudh Sharma


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

like image 41
Fangming Avatar answered Sep 30 '22 11:09

Fangming