1

谁能提供按钮背景的选择器文件。按下按钮时背景图像会发生变化。我将为按钮的背景设置自定义图像。可绘制文件的内容是 listbackground什么?

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="40dp"
        android:text="Button 1" 
        android:background="@drawable/listbackground"/>

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@+id/button1"
        android:layout_below="@+id/button1"
        android:layout_marginTop="37dp"
        android:text="Button 2" 
        android:background="@drawable/listbackground"/>

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@+id/button2"
        android:layout_centerVertical="true"
        android:text="Button 3" 
        android:background="@drawable/listbackground"/>

    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button3"
        android:layout_below="@+id/button3"
        android:layout_marginTop="48dp"
        android:text="Button 4" 
        android:background="@drawable/listbackground"/>

</RelativeLayout>
4

1 回答 1

3

列表背景.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_focused="true" android:drawable="@drawable/mainfocussed"></item>
    <item android:state_pressed="true" android:drawable="@drawable/mainpressed"></item>
    <item android:drawable="@drawable/main"></item>

</selector>
于 2012-04-16T10:09:07.900 回答