以编程方式更改布局的背景颜色

时间:2013-05-07 03:49:18

标签: android android-layout android-drawable

我有使用表格布局的表格。我有每列的可绘制资源。可绘制的资源就在这里。

<shape android:shape= "rectangle">
      <solid android:color="@color/white"/>
      <stroke android:width="1dp" android:color="@color/red"/>
      <size android:width="100dp" android:height="50dp"/>
      <padding
          android:left="5dp"
          android:top="5dp"
          android:right="5dp"
          android:bottom="5dp" />
</shape>

我使用了setBackgroundResource()  方法。我的问题是我想在运行时改变某些列的背景颜色取决于逻辑。当我使用setBackgroundColor方法时,该列的可绘制资源已经消失。有没有办法做到这一点?实际上我不想为该列创建另一个drawable。这可能是第二种方式。

0 个答案:

没有答案
相关问题