ImageButton问题(默认黄色)

时间:2011-08-10 02:29:45

标签: android imagebutton

我有一个ImageButton,当我们点击它为蓝色时,它会改变它的背景。 然而,当我点击它时,我有蓝色作为背景,但我也有一个黄色(Android在任何按钮中使用的默认值)。 IMAGE LINK 我怎么解决这个问题 ? 谢谢你的帮助。

<ImageButton android:id="@+id/test"  android:layout_below="@id/button" android:src="@drawable/settings_xml"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"  android:gravity="center"/>

此XML文件(settings_xml.xml)位于/ res / drawable-mdpi

<?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/blue" /> <!-- pressed -->

     <item android:drawable="@drawable/stock" /> <!-- default -->
 </selector>

我是否要将XML文件放在ldpi和hdpi中?

1 个答案:

答案 0 :(得分:0)

您可以将图像按钮的背景颜色设置为黄色,因此每当您点按图像按钮时,只会显示黄色并且会显示黄色。不是蓝色。