ANDROID笔记:Button的简单使用
16lz
2021-01-23
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 <Button16 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 <Button25 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>
更多相关文章
- Android USB状态监控(解决scheme="file")
- Android - GridView,自定义开关控件,状态选择器selector,自定义对话
- Android如何使布局中图(ImageButton)和文字(TextView)同时获得press
- 《Android/OPhone开发完全讲义》连载(5):Notification与状态栏信息
- Android selector 状态选择器
- Android selector状态选择器的使用详解
- Android中webview加载的网页上的按钮点击失效
- Android——按钮类控件
- Android 10 添加AM/PM在状态栏和锁屏