0
我设置了一个xml布局,其上有一个按钮,该按钮同时具有文本和图像。为了让图像看起来不紧张,我引用了一个位图xml文件并调整图像的重力。我还想在用户点击按钮时更改按钮上的图像。为此,我有一个状态列表xml文件。这两个组件在提及时都能单独正确运行,但我似乎只能一次完成这一项。有没有办法引用多个可绘制文件,或将它们合并为一个的方法?参考位图和状态列表drawables
homescreen.xml
<Button
android:id="@+id/bHome"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:layout_weight="2"
android:background="@drawable/homebutton"
android:text="Home"
android:textColor="#FFFFFF"
android:gravity="bottom|center">
</Button>
homebutton.xml
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/homeimage"
android:gravity="center"/>
homebuttonclicked.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/homeclicked" android:state_pressed="true" ></item>
<item android:drawable="@drawable/homeclicked" android:state_focused="true"></item>
<item android:drawable="@drawable/home"></item>
</selector>