在android中更改xml形状的背景颜色

时间:2014-11-06 19:07:05

标签: android xml drawable shape

我有一个我在xml文件中创建的形状,如下所示

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/shape">
<padding
    android:left="2dp"
    android:top="2dp"
    android:right="2dp"
    android:bottom="2dp" />
<corners android:radius="10dp" />
<solid android:color="@color/red" />
</shape>

在我的应用程序中,我有10-14个视图,上面的形状作为背景,但是对于每个视图,我需要有一个单独的形状文件,只是为了改变每个视图的颜色。有什么方法可以使用一个文件并在创建新形状时更改背景颜色?在创建形状视图时,是否可以直接在xml文件中执行此操作?

0 个答案:

没有答案
相关问题