我有一个textview和它的背景设置使用drawable资源。如何将属性动态分配给drawable?
<TextView
android:id="@+id/label1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Label1"
android:textColor="#FFFFFF"
android:background="@drawable/rounded_label"
android:layout_below="@id/snippet"
android:layout_toRightOf="@id/label"
android:layout_alignParentBottom="true"
>
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#000000"/>
<corners android:radius="3px"/>
<padding android:left="0dp"
android:top="0dp" android:right="0dp"
android:bottom="dp" />
</shape>
在<solid>
分配颜色必须在运行时不使用XML使用代码来执行rounded_label.xml?
在此先感谢。
http://stackoverflow.com/questions/ 5940825/android-change-shape-color-in-runtime 你检查过吗? – Lavanya
谢谢罗莎莉,那是我需要的东西。 – siva