Questions tagged [layerdrawable]

A Drawable that manages an array of other Drawables. These are drawn in array order, so the element with the largest index will be drawn on top.

A Drawable that manages an array of other Drawables. These are drawn in array order, so the element with the largest index will be drawn on top.

Click Here for documentation.

59 questions
19
votes
2 answers

How to merge two Drawables dynamically in Android?

so I have two different Drawables which I need to merge and get a single Drawable at runtime. I want the first Drawable to be at the top and the other one at the bottom. I came across LayerDrawable and it looks like it's exactly what I need, but I'm…
akshayt23
  • 2,793
  • 3
  • 21
  • 29
19
votes
1 answer

Changing color in a shape inside a layer-list programmatically

I am trying to change programmatically the color of the selectable_kachel_shape. Here is the xml file: kachel_ticked_style.xml
Stam
  • 2,410
  • 6
  • 32
  • 58
16
votes
0 answers

LayerDrawable addLayer in < API level 23

Is there a way add a layer to a LayerDrawable on API < 23? Do I have to create a new LayerDrawable using the constructor just adding the new layer?
Veneet Reddy
  • 2,707
  • 1
  • 24
  • 40
12
votes
2 answers

LayerDrawable programmatically

Since my application's color theme is dynamic i can only create background drawables using colors and shapedrawables, i want to build a edittext background drawable with colors and shapes as shown below. But i want to do this programatically How to…
zaaak
  • 521
  • 1
  • 4
  • 9
9
votes
1 answer

How to make a circular drawable with stroke, programmatically?

Background I'm trying to have a filled circle, with a stroke of certain color and width, and an image inside. This can easily be done in XML, as such (this is just a sample) :
android developer
  • 114,585
  • 152
  • 739
  • 1,270
9
votes
3 answers

Android: set color programmatically to ProgressBar

I would like to set color programmatically to the progress bar primaryProgress, secondaryProgress as the color will be changed according to the background color of the screen. Code: LayerDrawable progressDrawable = (LayerDrawable)…
pearmak
  • 4,979
  • 15
  • 64
  • 122
6
votes
3 answers

Drawable already belongs to another owner but does not expose a constant state

Error: Invalid drawable added to LayerDrawable! Drawable already belongs to another owner but does not expose a constant state. I suddenly noticed this error today, and I'm not sure if it was because I just updated my testing device to Android 8.0.…
eckc
  • 488
  • 6
  • 13
6
votes
2 answers

Change bottom property of item of layer-list Drawable programmatically

I am creating a LayerDrawable that creates bottom stroke but i dont know how to give bottom margin of a layer(Drawablw). .. …
Sachin Chandil
  • 17,133
  • 8
  • 47
  • 65
4
votes
1 answer

Diagonal line across view

Based on some condition, I have to diagonally cut the list cell. For this I have made diagonal drawable image using this code: diagonal_line.xml
seema
  • 991
  • 1
  • 13
  • 27
4
votes
1 answer

Android StateListDrawable pressed state always show last added

I have a custom button, and changed its pressed and default color by programmatically. public class CustomApplicationButton extends Button { public CustomApplicationButton(Context context) { this(context, 0, 0, 0); } public…
yasinkafadar
  • 229
  • 1
  • 12
4
votes
0 answers

item.getIcon() ALWAYS NULL

I stumbled upon this tutorial about in-app notifications on the ActionBar. http://www.jmhend.me/layerdrawable-menuitems All I get is NullPointer inside android.graphics.drawable.LayerDrawable when calling item.getIcon() on the line mentioned in this…
4
votes
1 answer

Apply ColorFilter to a Drawable inside a LayerDrawable

I want to have two cars in different colors (let's say red and blue) displayed at the same time for my game and to do so I use the same LayerDrawable (which is set as an image resource to an ImageView) for both cars:
Mino
  • 264
  • 3
  • 18
4
votes
2 answers
3
votes
1 answer

MenuItem.setIcon throws NullPointerException when using BottomNavigationBar

I swapped out the drawer-navigation with a bottomnavigationbar and found out that I couldn't use actionviews any longer, which is why I used LayerDrawables for my icons. final Menu menu = bottomNavigationView.getMenu(); notificationBullet = new…
3
votes
1 answer

Exception from LayerDrawable

I've an android app that using android support library version 23.2.1 and everything is working fine. However, I've updated the android support library version to 25.2.0 yesterday and realize some of the user are getting this exception (through…
1
2 3 4