次を使用して、このボタンに画像を追加できます。
android:background="@drawable/image_name"
このボタンの背景に単に色を追加したい場合は、次のように行うことができます。
android:background="#ff0000" // color code for red color
さらに、次のようにテキストの色を指定できます。
android:textColor="#0000ff" // color code for blue color
mybutton_style.xml
ボタンが押されているときや押されているときなど、さまざまなイベントでボタンの背景を変更する場合は、drawable
フォルダ内にxmlファイルを作成する必要があります。
// code for mybutton_style.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/btn_image_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/btn_image_focussed" /> <!--focused -->
<item android:drawable="@drawable/btn_image_default" /> <!-- default -->
</selector>
その後、ボタンの背景として指定する必要があります。
android:background="@drawable/mybutton_style"