Questions tagged [shapedrawable]
99 questions
10
votes
3 answers
Drawing Circle programmatically using Android ShapeDrawable
I have a requirement in my project to draw a circle in runtime dynamically. So for that purpose I am using ShapeDrawable to create circle programmatically, but unfortunately I could not find any class or methods inside ShapeDrawable for CircleShape,…

Chandru
- 5,954
- 11
- 45
- 85
10
votes
1 answer
How to make bottom border in drawable shape XML selector?
I'm trying to create a drawable shape with different states for my button. So I wrote this:
-

Igal
- 5,833
- 20
- 74
- 132
9
votes
3 answers
Animate Android Ring Shape's sweep angle
Attempting to animate the Android Ring Shape to produce an effect similiar to the shown sequence of images.
I have found the Shape Drawable type of…

Leon Storey
- 3,274
- 2
- 25
- 40
7
votes
3 answers
RotateDrawable Programmatically in android
How can i give fromFegrees , toDegrees and android:color="#000000" programmatically?
-

Sanket Kachhela
- 10,861
- 8
- 50
- 75
6
votes
2 answers
Add shadow to the ShapeDrawable programmatically
I am trying to make buttons with different gradients programmatically. I use ShapeDrawable and it works like a charm.
RoundRectShape rs = new RoundRectShape(new float[] { 12f, 12f, 12f, 12f, 12f, 12f, 12f, 12f }, null, null);
ShapeDrawable sd = new…

stevo.mit
- 4,681
- 4
- 37
- 47
6
votes
1 answer
How are you supposed to use a ShapeDrawable with a PathShape to draw a line on a custom View?
I am attempting to draw a line in a custom View. Here I've created a simple Path with just a single segment, created a PathShape from that, and finally stuck that into a ShapeDrawable with the intention of using that to draw on the Canvas inside…

Daniel
- 497
- 1
- 7
- 20
6
votes
1 answer
Annoying behavior for a ShapeDrawable in Android
I am using ShapeDrawable for LinearLayouts background. The Shapes are made by cod as I need to dynamically assign colors to them, depending on conditions.
Here is my custom Shape
public class CustomShapeDrawable extends ShapeDrawable {
private…

Alin
- 14,809
- 40
- 129
- 218
5
votes
1 answer
Why set a drawable shape in layout background will be warn?
Why setting a layout background with shape drawable causes a warning on Android Studio 1.4 telling that cannot set background in RelativeLayout?
Android Studio warning about invalid background:
Drawable shape used as background:

Fang
- 3,652
- 4
- 16
- 30
5
votes
1 answer
Can I override some attribute of drawable shape?
I have two buttons, they are same shape, only color is different
b1.xml
…

CL So
- 3,647
- 10
- 51
- 95
5
votes
1 answer
Shape Android Material Design
I want to ask about how to create animation for changing shape in android material design. And this is video that I got from Android Material Design guidelines.
Material can change shape
Thank you.

Samuel Susanto
- 61
- 3
5
votes
1 answer
android:shape="line" not visible
I have the following drawable shape:

Ralph Bergmann
- 3,015
- 4
- 30
- 61
4
votes
3 answers
Call setImageDrawable from RemoteViews
I have done this in an Activity and it works perfectly.
ImageView myImage = (ImageView) findViewById(R.id.myImageView);
ShapeDrawable mDrawable;
mDrawable = new ShapeDrawable(new…

Ranhiru Jude Cooray
- 19,542
- 20
- 83
- 128
4
votes
1 answer
ActionBar item is not showing when a ShapeDrawable is set as it's icon
I am working on a simple project and I want to avoid the PNG images as much as possible. I need a '+' (Add) button and I created it using the ShapeDrawable with the given code.
res/drawable/plus_icon_drawable.xml

gnuanu
- 2,252
- 3
- 29
- 42
4
votes
4 answers
Dynamically change action bar divider color (android:bottom for programmatically generated ShapeDrawable)?
I'm trying to change the color of the divider bar at the bottom of the action bar programmatically. My strategy is to set the action bar background to a programmatically generated LayerDrawable containing ShapeDrawable rectangles, based on this…

user460847
- 1,578
- 6
- 25
- 43
4
votes
2 answers
setColor method of GradientDrawable drawing different color
I have a shape in layer-list and my goal is to change color of the shape programmatically at runtime. I have String for HEX code and I used Color.parseColor() to parse it and I passed to setColor method. Whenever I run the application it shows…

Gokhan Arik
- 2,626
- 2
- 24
- 50