my problem is that I have a button with drawable background, it's xml code is following
<Button
android:id="@+id/prolongate"
style="@style/styleBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="32dp"
android:layout_marginEnd="32dp"
android:layout_marginStart="32dp"/>
here, according to style, background of this button is drawable file with following code
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ff3add79" />
<corners android:radius="128dp" />
</shape>
now I want to change background color of this button dynamically according to values, which is token from NumberPicker, but without changing its shape. I cannot create one file to one value, hardcoding is not suitable here)). How can I solve this problem?
Dynamic changing the color of Drawables is possble using ColorFilter.
https://developer.android.com/reference/android/graphics/ColorFilter also check this for modes https://developer.android.com/reference/android/graphics/PorterDuff.Mode