设置圆角背景边框的的按钮

roundbutton

项目地址: czy1121/roundbutton
简介:可设置圆角背景边框的的按钮


通过调节色彩明度自动计算按下(pressed)状态颜色

可设置圆角背景边框的的按钮

通过调节色彩明度自动计算按下(pressed)状态颜色

roundbutton

Gradle

repositories { 
    maven { url "https://jitpack.io" }
}
dependencies {
    compile 'com.github.czy1121:roundbutton:1.0.0'
}

Usage

XML

<com.github.czy1121.view.RoundButton
    style="@style/RoundButton"
    android:text="Text"
    app:btnCornerRadius="10dp" 
    app:btnSolidColor="#3F51B5"/>

<com.github.czy1121.view.RoundButton
    style="@style/RoundButton.Two"
    android:text="Text"
    android:textColor="#3F51B5"
    app:btnCornerRadius="10dp"
    app:btnPressedRatio="1.5"
    app:btnStrokeColor="#3F51B5"/>

属性

<declare-styleable name="RoundButton">
    <!-- 背景色 -->
    <attr name="btnSolidColor" format="color"/>
    <!-- 边框色 -->
    <attr name="btnStrokeColor" format="color"/>
    <!-- 边框厚度 -->
    <attr name="btnStrokeWidth" format="dimension"/>
    <!-- 边框虚线长度 -->
    <attr name="btnStrokeDashWidth" format="dimension"/>
    <!-- 边框虚线间隙 -->
    <attr name="btnStrokeDashGap" format="dimension"/>
    <!-- 圆角半径,stadium 表示半径为 min(height,width) / 2-->
    <attr name="btnCornerRadius" format="dimension">
        <enum name="stadium" value="-1"/>
    </attr>
    <!-- 自动计算按下(pressed)状态颜色的系数, 值为 0 时不自动计算 -->
    <attr name="btnPressedRatio" format="float"/>
</declare-styleable>
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值