1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:orientation="vertical" > 6 7 <Button 8 android:layout_width="wrap_content" 9 android:layout_height="wrap_content" 10 android:background="@drawable/bnt_selector" 11 android:text="登陆" 12 android:textColor="#ffffff" /> 13 <!-- 不可用状态 --> 14 15 <Button 16 android:layout_width="wrap_content" 17 android:layout_height="wrap_content" 18 android:background="@drawable/bnt_selector" 19 android:enabled="false" 20 android:text="登陆不可用" 21 android:textColor="#ffffff" /> 22 <!-- 带图片的按钮 --> 23 24 <Button 25 android:layout_width="wrap_content" 26 android:layout_height="wrap_content" 27 android:background="@drawable/bnt_selector" 28 android:drawableTop="@drawable/ic_launcher" 29 android:text="登陆" 30 android:textColor="#ffffff" 31 android:textSize="20sp" /> 32 33 </LinearLayout>
1 <?xml version="1.0" encoding="utf-8"?> 2 <selector xmlns:android="http://schemas.android.com/apk/res/android"> 3 4 <!-- 不可用状态 --> 5 <!-- 写在前面 --> 6 <item android:drawable="@drawable/btn_small_null" android:state_enabled="false"></item> 7 <!-- 点击状态 --> 8 <item android:drawable="@drawable/btn_small_hover" android:state_pressed="true"></item> 9 <!-- 未点击状态(平常状态) --> 10 <item android:drawable="@drawable/btn_small" android:state_pressed="false"></item> 11 12 </selector>