0

What method can I use to get the layer-list item ID (first_image) in Java class?

layers.xml:

<item android:id="@+id/first_image">
  <bitmap android:src="@drawable/android_red"
    android:gravity="center" />
</item>

amir
  • 13
  • 3
  • Does this answer your question? [How to change a layer-list drawable?](https://stackoverflow.com/questions/8018435/how-to-change-a-layer-list-drawable) – Anisur Rahman Tonu Jun 02 '20 at 03:56

1 Answers1

0

You can programmatically access item of layer-list by ID as given below.

GradientDrawable gradientDrawable = (GradientDrawable) layerDrawable
                .findDrawableByLayerId(R.id.first_image);
Prince Dholakiya
  • 3,017
  • 23
  • 38