我正在尝试更改Android默认按钮的样式。我在res文件夹中的drawable文件夹中创建了一个名为custom_button.xml
的xml文件,并在xml布局文件中引用了它,但是当我运行应用程序时,按钮样式没有改变,而是我丢失了原始按钮。
custom_button.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
<solid
android:color="#FF0000" />
</shape>
main.xml
<TextView
android:id="@+id/textView1"
android:layout_width="85dp"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="#6600ff"
android:text="" />
<Button
android:id="@+id/button_getDraw"
style="?android:attr/buttonStyleSmall"
android:background="@drawable/custom_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_getDraw"
android:onClick="getLotteryDrawFromWebsite" />
<Button
android:id="@+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_check"
android:onClick="checkNumbers"
android:enabled="false" />
问题是什么?先谢谢..
答案 0 :(得分:3)
将custom_button xml更改为此。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FF0000"/>
答案 1 :(得分:0)
尝试使用此link .... 你也可以设置按钮选择效果。