Questions tagged [shapes]

Questions related to drawing or defining shapes.

A shape is a geometric representation of some object, defined by the external boundaries which encompass the object.

For 2-D shapes like the circle, , and rectangle their shape is constructed of lines connected together.

3-D shapes are defined by a 2-D which envelopes the interior 3-D volume.

4362 questions
823
votes
19 answers

How to define a circle shape in an Android XML drawable file?

I have some problems finding the documentation of the definitions of shapes in XML for Android. I would like to define a simple circle filled with a solid color in an XML File to include it into my layout files. Sadly the Documentation on…
Janusz
  • 187,060
  • 113
  • 301
  • 369
303
votes
10 answers

How to make gradient background in android

I want to create gradient background where the gradient is in the top half and there's a solid color in the bottom half, like in this image below: I can't because the centerColor spreads out to cover the bottom and top. How can I make a…
kongkea
  • 9,788
  • 12
  • 39
  • 49
230
votes
19 answers

Set android shape color programmatically

I am editing to make the question simpler, hoping that helps towards an accurate answer. Say I have the following oval shape:
Cote Mounyo
  • 13,817
  • 23
  • 66
  • 87
229
votes
12 answers

Rounded corner for textview in android

I have a textview and want its corner to be in round shape. I already know it can be done using android:background="@drawable/somefile". In my case, this tag is already included so cannot use again. e.g android:background="@drawable/mydialogbox" is…
Sanjeev Yadav
  • 2,921
  • 7
  • 24
  • 23
181
votes
6 answers

Multi-gradient shapes

I'd like to create a shape that's like the following image: Notice the top half gradients from color 1 to color 2, but theres a bottom half that gradients from color 3 to color 4. I know how to make a shape with a single gradient, but I'm not sure…
Andrew
  • 20,756
  • 32
  • 99
  • 177
179
votes
3 answers

Border in shape XML

I am trying to make a drawable to use for a button. I would like it to have this coloring, with a 2px border around it. Everything works just fine except I cannot get the border to show up...
Matt
  • 5,461
  • 7
  • 36
  • 43
138
votes
14 answers

How to change shape color dynamically?

I have
chobo2
  • 83,322
  • 195
  • 530
  • 832
88
votes
7 answers

Android: Using linear gradient as background looks banded

I'm trying to apply a linear gradient to my ListView. This is the content of my drawable xml:
Francesco Laurita
  • 23,434
  • 8
  • 55
  • 63
87
votes
7 answers

I need to change the stroke color to a user defined color. Nothing to do with the state

I need to change the stroke color from the app. The user is able to change the background color so I need to also let them change the stroke (outline) of the button. As its is already set in the drawable (sample below) I have not found a way to…
Mark Worsnop
  • 4,407
  • 15
  • 54
  • 79
75
votes
8 answers

Shape drawable as background, a line at the bottom

I am using a drawable as a background of a TextView just to have a divider line below the text. A achivied it with this drawable-xml:
ZoolWay
  • 5,411
  • 6
  • 42
  • 76
70
votes
6 answers

SVG to Android Shape

I'm wondering how vector drawing in Android with the Shape class may resemble another vector drawing standard. Since Shape is a Drawable, and Drawables are usually defined as XML, it sounds a lot like the vector drawing commands in SVG. My question…
Buggieboy
  • 4,636
  • 4
  • 55
  • 79
64
votes
3 answers

Drawing multiple shapes with ShapeDrawable in xml with Android

I am currently drawing a number of circles on a canvas in a custom view in code. the circles are static and do not change. I would like to draw them using a ShapeDrawable in xml to help clean up my code. I will have a number of different drawables…
skyfoot
  • 20,629
  • 8
  • 49
  • 71
60
votes
9 answers

Two Rectangles intersection

I have two rectangles characterized by 4 values each : Left position X, top position Y, width W and height H: X1, Y1, H1, W1 X2, Y2, H2, W2 Rectangles are not rotated, like so: +--------------------> X axis | | (X,Y) (X+W, Y) | …
Majid Laissi
  • 19,188
  • 19
  • 68
  • 105
59
votes
4 answers

what does numpy ndarray shape do?

I have a simple question about the .shape function, which confused me a lot. a = np.array([1, 2, 3]) # Create a rank 1 array print(type(a)) # Prints "" print(a.shape) # Prints "(3,)" b =…
Pumpkin C
  • 1,452
  • 6
  • 21
  • 27
57
votes
1 answer

How to get round shape in Android

How would I achieve a round shape in Android, like below, through an Android shape drawable:
AndroidDev
  • 2,627
  • 6
  • 29
  • 41
1
2 3
99 100