Questions tagged [android-shape]

This is a generic shape defined in XML.

This is a generic shape defined in XML.

Reference: http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape

191 questions
127
votes
20 answers

How to make a view with rounded corners?

I am trying to make a view in android with rounded edges. The solution I found so far is to define a shape with rounded corners and use it as the background of that view. Here is what I did, define a drawable as given…
Zach
  • 9,989
  • 19
  • 70
  • 107
103
votes
8 answers

Open-sided Android stroke?

Is it possible to create an Android shape object with stroke on only certain sides? Eg I have: Which is similar to this…
Reed Morse
  • 1,398
  • 2
  • 10
  • 17
96
votes
8 answers

How to make a shape with left-top round rounded corner and left-bottom rounded corner?

I want to make a shape with with left-top rounded corner and left-bottom rounded corner:
user256239
  • 17,717
  • 26
  • 77
  • 89
82
votes
5 answers

angle attribute in android gradient

I am going through test example. Where for some Image background they are using gradient, the code goes like this
Sharanabasu Angadi
  • 4,304
  • 8
  • 43
  • 67
61
votes
3 answers

What does top, left, right and bottom mean in Android Rect object

I have an Android project where I should make Apples fall. The apples are painted in a Rect. So I created a function that change the Rect position and repaint. Here's my function : private void updateApplesPosition() { for(Rect…
Hunsu
  • 3,281
  • 7
  • 29
  • 64
50
votes
9 answers

How to draw a circle inside a circle using Android xml shapes?

I'm trying to make a thumb for a seekbar for my app, and I want to have an inner circle surrounded by a different, larger (semi-transparent) outer circle. I'm trying to use layer-list, but I'm having issues. Below is my code...
jas7457
  • 1,971
  • 5
  • 30
  • 47
34
votes
4 answers

Ring shape in android

I have the following xml in drawable folder (circle_status.xml) to create a ring:
suanido
  • 751
  • 1
  • 7
  • 12
26
votes
8 answers

Add only top and bottom border on LinearLayout

I would like to add only a bottom and a top border on my Linearlayout. I have tried to do this :
wawanopoulos
  • 9,614
  • 31
  • 111
  • 166
25
votes
1 answer

filling a circle gradually from bottom to top android

I have created a circle with a stroke and white background using xml. How can this be filled gradually from bottom to top on user actions(e.g. on successive button press)? Is there any free library which can be used to achieve similar thing?
Kaps
  • 2,345
  • 2
  • 26
  • 37
18
votes
6 answers

Custom shaped Linearlayout with curved side in android

I am trying to make a custom shaped linearlayout like below I am trying to make only one side curved. Tried with corner radius but it doesn't give the same look as above. Already tried this background shape as below :-
UzUmAkI_NaRuTo
  • 565
  • 3
  • 8
  • 20
18
votes
3 answers

Android - make an arrow shape with xml

I want to make a button for my shape like this one Is there a way to do this with xml ? Like setting some points, in my case I have 5..
Boldijar Paul
  • 5,405
  • 9
  • 46
  • 94
17
votes
5 answers

How to show only top and bottom border

This is my XML code which works fine, the only problem is it's showing border on all four sides while I want only to show border on the top and on the bottom only. How can I do that?
user2761245
  • 245
  • 1
  • 2
  • 8
14
votes
4 answers

ImageView with only one rounded corner

I'm trying to make one rounded corner of ImageView like in the picture below but with bottom right corner. Tried using background shape but it's not working at all. All images loaded by Glide. Should i use something like ViewOutlineProvider? Is…
13
votes
3 answers

how to build a trapezoid shape in android?

how can I create a trapezoid shape like below image ? I don't want to use an image or 9.png .
S.M_Emamian
  • 17,005
  • 37
  • 135
  • 254
12
votes
4 answers

ShapeableImageView's stroke is getting cut by borders

I have a ShapeableImageView here, with 5dp stroke:
1
2 3
12 13