android - Different between direct embedded and use @ simple -
i trying create button style includes customize background , pressed background changes response. have done using , drawable.
the style
<style name="boltbutton" parent="android:style/widget.button"> <item name="android:background">@drawable/gree_btn_background</item> <item name="android:paddingtop">10dp</item> <item name="android:paddingbottom">10dp</item> </style>
/drawable/gree_btn_background.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="@color/btn_pressed"/> <item android:state_focused="true" android:drawable="@color/btn_focuse"/> <item android:drawable="@color/btn_green"/> </selector>
the above setting works, try remove drawable file , try put directly under <item name="android:background"></item>
, error comes out, different between using @
, directly use it? why above case didn't work?
the below code doesn't work
<item name="android:background"> <selector > <item android:state_pressed="true" android:drawable="@color/bolt_btn_pressed"/> <item android:state_focused="true" android:drawable="@color/bolt_btn_focuse"/> <item android:drawable="@color/bolt_btn_green"/> </selector> </item>
<item name="android:background"></item>
inside that, expecting id drawable, not <selector>
.
so should give drawable id give earlier <item name="android:background">@drawable/gree_btn_background</item>
Comments
Post a Comment