疯狂android讲义学习总结---各种按钮的制作

第一种:给按钮的文字加重影操作
<Button
android:id="@+id/register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/cancel"
android:layout_toLeftOf="@+id/cancel"
android:shadowColor="#aa5"
android:shadowDx="5"
android:shadowDy="5"
android:shadowRadius="1"
android:text="注册"
android:textSize="12pt"
android:background="@drawable/button_selector" />
重影操作主要涉及android的四个xml属性,分别是 shadowColor,shadowRadius,shadowDx,shadowDy。
第二种:用图片作为按钮
<Button
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText6"
android:layout_below="@+id/email"
android:layout_marginLeft="38dp"
android:background="@drawable/red"
android:text="取消"
android:textSize="12pt" />
第三种:在按的时候可以设置鼠标的动作 用drawable类,绘制xml文件
<Button
android:id="@+id/register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/cancel"
android:layout_toLeftOf="@+id/cancel"
android:text="注册"
android:textSize="12pt"
android:background="@drawable/button_selector" />

这里的button_selector是一个存放在,res/drawable/mdpi文件夹下的xml文件,内容如下
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 指定按钮按钮下时的图片 -->
<item android:drawable="@drawable/red" android:state_pressed="true"/>
<!-- 指定按钮松开时的图片 -->
<item android:drawable="@drawable/purple" android:state_pressed="false"/> </selector>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值