设置方法:
Button中引用android:background="@drawable/button_background_selector"
在文件夹drawable下定义button_background_selector.xml文件,如下:
05-06 18:14:42.730: E/AndroidRuntime(24114):
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #4: tag requires a 'drawable' attribute or child tag defining a drawable
05-06 18:14:42.730: E/AndroidRuntime(24114): at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:178)
05-06 18:14:42.730: E/AndroidRuntime(24114): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:885)
05-06 18:14:42.730: E/AndroidRuntime(24114): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:822)
05-06 18:14:42.730: E/AndroidRuntime(24114): at android.content.res.Resources.loadDrawable(Resources.java:2045)
05-06 18:14:42.730: E/AndroidRuntime(24114): ... 31 more
解决方法:
Button中引用background属性不变
更改button_background_selector.xml文件,如下:
并在colors.xml文件中增加如下定义: