0

I have an XML file in the drawable folder.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" 
    android:padding="10dp">
    <solid android:color="#2A3B5E"/>
    <corners
        android:bottomRightRadius="15dp"
        android:bottomLeftRadius="15dp"
        android:topLeftRadius="15dp"
        android:topRightRadius="15dp"/>
</shape>

I would like to change the color value. Is it possible to change the value programmatically?

Cœur
  • 37,241
  • 25
  • 195
  • 267
user2629828
  • 685
  • 1
  • 8
  • 13

2 Answers2

1

Already answered here!

It retrieves the background containing the drawable shape that you want to modify; otherwise you can instantiate programatically a new ShapeDrawable, assigning all the properties that you like.

Community
  • 1
  • 1
Simone Leoni
  • 316
  • 1
  • 9
0

You can do that via LevelListDrawable. Check android docs

Dmitry Nevzorov
  • 595
  • 8
  • 16