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笔记:Button的简单使用

更多相关文章

  1. Android USB状态监控(解决scheme="file")
  2. Android - GridView,自定义开关控件,状态选择器selector,自定义对话
  3. Android如何使布局中图(ImageButton)和文字(TextView)同时获得press
  4. 《Android/OPhone开发完全讲义》连载(5):Notification与状态栏信息
  5. Android selector 状态选择器
  6. Android selector状态选择器的使用详解
  7. Android中webview加载的网页上的按钮点击失效
  8. Android——按钮类控件
  9. Android 10 添加AM/PM在状态栏和锁屏

随机推荐

  1. Android之自定义标题栏(组合控件)
  2. slidingmenu框架
  3. android使用Canvas画柱状图和饼图源码
  4. android弹出单选、多选菜单
  5. A20启动LUNCH选项修改
  6. android活动的跳转到另一个活动
  7. android studio 2.0 引导页示例
  8. react-native调用Android原生模块
  9. Android(安卓)PatternMatcher
  10. android 检查可用网络