Questions tagged [shapedrawable]

99 questions
57
votes
7 answers

Android how to create triangle and rectangle shape programmatically?

How can we create ballon drawable shape as below. where we can change the color of it dynamically.
Dory
  • 7,462
  • 7
  • 33
  • 55
54
votes
8 answers

Shape Drawable Size not working

I have a very simple shape that I want to set the width of: However, when I assign this to the background of a EditText it just…
chubbsondubs
  • 37,646
  • 24
  • 106
  • 138
42
votes
4 answers

Applying ColorFilter to ImageView with ShapedDrawable

I have an ImageView with android:src set to a ShapedDrawable, namely a white circle. What I want is to colorize this ImageView in runtime responding to some events. imgView.setColorFilter seems to be solution, but after using this (tried different…
aplavin
  • 2,199
  • 5
  • 32
  • 53
35
votes
5 answers

Gradient Radius as percentage of screen size

I'm trying to create a shape drawable with radial gradient background, with radius that will adjust to the screen size (take a look at the relevant documentation). This is my code:
shaylh
  • 1,871
  • 3
  • 17
  • 19
34
votes
2 answers

Android dashed line drawable potential ICS bug

The following is a dashed line, defined as a ShapeDrawable in XML:
Chris Horner
  • 1,994
  • 2
  • 16
  • 26
33
votes
3 answers

how to add shadow effect on drawable in android

I have created chat bubble with drawable which looks fine, now I want to add shadow effect below the drawable so it make 3d effect.I don't want to use 9-pitch image. I just want to know how i can add shadow effect on this drawable. my code is…
maddy d
  • 1,530
  • 2
  • 12
  • 23
31
votes
2 answers

Drawing programmatically oval shape with border (corner radius) on Android

I`m trying to draw custom ShapeDrawable with OvalShape, filled with white and with grey border. I created a drawable like this: ShapeDrawable drawable = new ShapeDrawable(new…
L3K0V
  • 1,104
  • 1
  • 9
  • 24
30
votes
3 answers

Google Maps API v2 Android add shape drawable as marker

I've been trying to add a shape drawable as the marker icon for a marker I want to add on the map. shape looks like this (res/drawable/blue_circle.xml):
21
votes
2 answers

How to create shape with solid, corner, stroke in Java Code?

I have a shape defined in the xml file below, now I want to change to solid color programmatically.
srain
  • 8,944
  • 6
  • 30
  • 42
20
votes
6 answers

How to programmatically create a round cornered border using ShapeDrawable in android?

I need to create a border with rounded corners programatically by extending ShapeDrawable. I need to have a black border with rounded corners with the pixels on the outside being white and the inner pixels being transparent. The code I have at the…
user1592512
  • 423
  • 2
  • 4
  • 7
18
votes
10 answers

How can I create a rectangle with two curved sides in XML drawable?

I want the left and right sides (not the corners) of the rectangle to be curved. Or say the top and bottom sides of an oval shape straight. How can I achieve something like this?
user1372984
15
votes
3 answers

Create borders on a android view in drawable xml, on 3 sides?

I want to make a drawable for my Android button, defined as drawable. I found I could set all the borders by using a rectangle, but I got kinda stuck when I wanted it on three sides. I want for example have either the top or the bottom open. Could…
user717572
  • 3,626
  • 7
  • 35
  • 60
14
votes
4 answers

Custom (gradient) background of ActionBar Compat

I am using Action Bar Compat so that my action bar with navigation drawer was backward compatible down to API level 9 and I want to change the background of the action bar. I copied the code from Android Developers:
Marcel Bro
  • 4,907
  • 4
  • 43
  • 70
13
votes
3 answers

Color State List not recognized in Shape Drawable

I define following drawable my_background_drawable.xml:
a.ch.
  • 8,285
  • 5
  • 40
  • 53
11
votes
4 answers

How to create parallelogram shape background?

I am trying to make parallelogram background for my textview but it is not displaying properly...it display following output
fazilpuriasa
  • 297
  • 3
  • 8
  • 19
1
2 3 4 5 6 7