我的问题是我有一个带可绘制背景的按钮,它的XML代码如下
<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"/>
这里,根据样式,这个按钮的背景是带有以下代码的可绘制文件
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ff3add79" />
<corners android:radius="128dp" />
</shape>
现在,我想根据值动态更改此按钮的背景色,这是数字选择器中的标记,但不更改其形状。我不能创建一个文件到一个值,硬编码在这里不合适)。我如何解决这个问题?