android 自定义custombutton,Button 自定义(一)-shape

需求:自定义Button,使用系统自定义Shape;

效果图:

1.默认状态

28606746cb46eb8dfc8243ecdc06abf4.png

2.选中状态

7b77a7952a80fe4ac4576a9eb988d80c.png

实现分析:

1.目录结构:

728420696b56120887a9c14c929fce69.png

代码实现:

1.button_normal.xml

android:bottomLeftRadius="6dp"

android:bottomRightRadius="6dp"

android:topLeftRadius="6dp"

android:topRightRadius="6dp" />

2.button_select.xml

android:bottomLeftRadius="6dp"

android:bottomRightRadius="6dp"

android:topLeftRadius="6dp"

android:topRightRadius="6dp" />

solid:实心,就是填充的意思

corners:圆角

android:radius为角的弧度,值越大角越圆。

3.button_selector.xml

4.fragment_main.xml

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context="com.jjc.demo.MainActivity$PlaceholderFragment" >

android:id="@+id/button_test"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="@drawable/button_selector"

android:text="推荐组合"

android:textColor="@android:color/white" />

android 自定义Button,抛弃写shape文件

标签: android 控件  自定义 2017年05月27日 17:52:13 611人阅读 评论(0) 收藏 举报 分类: 自定义View(2) 作者同类文章 X 版权声明:本文为博主原创文章 ...

Android-----使用Button特效 selector+shape

当然除了使用drawable这样的图片外今天谈下自定义图形shape的方法,对于Button控件Android上支持以下几种属性shape.gradient.stroke.corners等. 我们就以 ...

Android自定义图形shape

在Android开发过程中,经常需要改变控件的默认样式, 那么通常会使用多个图片来解决.不过这种方式可能需要多个图片,比如一个按钮,需要点击时的式样图片,默认的式样图片. 这样就容易使apk变大.另一 ...

Android自定义drawable(Shape)详解

在Android开发过程中,经常需要改变控件的默认样式, 那么通常会使用多个图片来解决.不过这种方式可能需要多个图片,比如一个按钮,需要点击时的式样图片,默认的式样图片. 这样就容易使apk变大. 那 ...

18 UI美化自定义形状shape

自定义某个控件的形状 如 圆角 巨型 环形 : 在工程文件的新建 res/drawable/shape文件(以下键一个圆角) <?xml version="1.0" enco ...

Button 自定义图片,代码绘制样式,添加音效的方法

Button自己在xml文件中绑定监听器

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值