万能的CYButton-告别各种shape文件

万能的CYButton-告别各种shape文件
参考:https://github.com/zhxhcoder/CYButton

CYButton

CYButton 告别各种shape文件,并支持按压效果

先看效果图


cybutton.gif
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:CYButton="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.zhxh.cybutton.component.CYButton
        android:id="@+id/btnGo"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="150dp"
        android:layout_height="40dp"
        android:text="3"
        app:XborderRadius="0dp"
        app:XbuttonColor="#ff700332"
        app:XinnerRadius="0dp"
        app:XouterRadius="5dp"
        app:XshadowColor="#ffbba332"
        app:XshadowEnabled="false"
        app:XshadowHeight="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.458" />

    <com.zhxh.cybutton.component.CYButton
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="150dp"
        android:layout_height="40dp"
        android:text="4"
        app:XborderRadius="0dp"
        app:XbuttonColor="#ffaa1332"
        app:XinnerRadius="0dp"
        app:XouterRadius="45dp"
        app:XshadowColor="#ffbba332"
        app:XshadowEnabled="false"
        app:XshadowHeight="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.585" />

    <com.zhxh.cybutton.component.CYButton
        android:layout_width="150dp"
        android:layout_height="40dp"
        android:text="6"
        app:XborderRadius="12dp"
        app:XbuttonColor="#0ff000"
        app:XinnerRadius="10dp"
        app:XouterRadius="10dp"
        app:XshadowColor="#0000000"
        app:XshadowEnabled="false"
        app:XshadowHeight="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.836" />

    <com.zhxh.cybutton.component.CYButton
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="150dp"
        android:layout_height="40dp"
        android:text="5"
        app:XborderRadius="0dp"
        app:XbuttonColor="#ff134432"
        app:XinnerRadius="0dp"
        app:XouterRadius="0dp"
        app:XshadowColor="#ffbba332"
        app:XshadowEnabled="false"
        app:XshadowHeight="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.726" />

    <com.zhxh.cybutton.component.CYButton
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:text="2"
        app:XborderRadius="0dp"
        app:XbuttonColor="#ffaaa332"
        app:XinnerRadius="0dp"
        app:XouterRadius="45dp"
        app:XshadowColor="#ffbba332"
        app:XshadowEnabled="false"
        app:XshadowHeight="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.348" />

    <com.zhxh.cybutton.component.CYButton
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:text="1"
        app:XborderRadius="0dp"
        app:XbuttonColor="#ff11a332"
        app:XinnerRadius="0dp"
        app:XouterRadius="45dp"
        app:XshadowColor="#ff11a332"
        app:XshadowEnabled="false"
        app:XshadowHeight="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.159" />

</android.support.constraint.ConstraintLayout>

buttonColor 设置button的前景色
outerRadius 设置button的圆角角度
...

    <com.zhxh.cybutton.component.CYButton
        android:layout_width="150dp"
        android:layout_height="40dp"
        android:text="6"
        app:XborderRadius="1dp"
        app:XbuttonColor="#0ff000"
        app:XinnerRadius="10dp"
        app:XouterRadius="10dp"
        app:XshadowColor="#000000"
        app:XshadowEnabled="false"
        app:XshadowHeight="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.836" />

XborderRadius 存在值时表示空心button

第二版更新为未完待续

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • shape可以定义一个View空间的,圆角,边框,padding,大小,填充颜色,渐变颜色。 shape定义 1 ...
    shenlong77阅读 892评论 0 1
  • Q1 最想学习新技能 游泳 旱鸭子了这么多年,突然对水中的世界有一种向往,而且,水里扑腾是...
    不美千树阅读 481评论 0 5
  • 该走的都会走,以为相机可以留住时光
    一块瘦司阅读 168评论 0 0
  • 王徽阅读 767评论 3 6