我用这个布局按钮颜色(蓝色):按钮颜色没有变化
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape>
<solid
android:color="#449def" />
<stroke
android:width="1dp"
android:color="#2f6699" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item>
<shape>
<gradient
android:startColor="#449def"
android:endColor="#2f6699"
android:angle="270" />
<stroke
android:width="1dp"
android:color="#2f6699" />
<corners
android:radius="4dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
</selector>
当我尝试改变颜色,它不会改变它仍然是蓝色的任何变化我做的。
我的strings.xml使用:
<style name="mybuttons">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#ffffff</item>
</style>
下面是main.xml中的一部分:
<Button
android:id="@+id/select_c"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/choose_c"
android:layout_marginTop="120dip"
android:background="@drawable/blue_button"
style="@style/mybuttons"
/>
继'奥利C'回答你可能没有设置的选择背景,按钮的背景,因为我测试你的选择并按照预期运行指定选择项。 – Luksprog 2012-02-25 16:12:55
@slukian:我更新了。问题是如果我改变颜色,它仍然是一样的。 – George 2012-02-25 16:37:46
我不认为我明白你想达到的目标。你想要改变按钮背景的颜色,选择器的颜色(你在哪里尝试这样做?)?我看到你为这个按钮设置了一些样式,但是你没有那种样式的按钮背景颜色,只是按钮的文本。 – Luksprog 2012-02-25 17:01:25