一个支持渐变背景、圆角、阴影的Button

预览:

device-2017-10-22-090603.png

Github

https://github.com/duweigang/GradientButton
注:为了防止以后有需求,可以star一下( ⊙ o ⊙ )!

Gradle

dependencies {
    compile 'com.dagang:gradient-button:1.0.1'
}

使用

<com.dagang.library.GradientButton
        android:layout_width="200dp"
        android:layout_height="80dp"
        app:button_end_color="#EEA9B8"
        app:button_gradient_orientation="LEFT_RIGHT"
        app:button_is_shadowed="true"
        app:button_press_end_color="#EEE5DE"
        app:button_press_start_color="#EEA9B8"
        app:button_radius="30dp"
        app:button_shadow_angle="90"
        app:button_shadow_color="#EE799F"
        app:button_shadow_distance="5dp"
        app:button_shadow_radius="10dp"
        app:button_size="10sp"
        app:button_start_color="#EEE5DE"
        app:button_text="Rich Button"
        app:button_text_color="#9F79EE" />

动态代码修改

GradientButton gradientButton = (GradientButton) findViewById(R.id.magic_button);
        TextView textView = gradientButton.getButton();
        textView.setText("Custom Button");
        textView.setTextColor(Color.BLUE);
        gradientButton.setButtonRadius(20);
        gradientButton.setShadowRadius(10);
        gradientButton.setShadowColor(Color.RED);
        gradientButton.setButtonStartColor(Color.parseColor("#EEE5DE"));
        gradientButton.setButtonEndColor(Color.parseColor("#9370DB"));
        gradientButton.setButtonPressStartColor(Color.BLACK);
        gradientButton.setButtonPressEndColor(Color.BLACK);
        gradientButton.setButtonGradientOrientation(GradientButton.LEFT_RIGHT);
        gradientButton.getButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "onClick", Toast.LENGTH_LONG).show();
            }
        });
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 180,769评论 25赞 708
  • 太长了,还是转载吧...今天在看博客的时候,无意中发现了@Trinea在GitHub上的一个项目Android开源...
    庞哈哈哈12138阅读 20,466评论 3赞 283
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 16,003评论 2赞 45
  • 那轰隆隆的雷声犹如战车般碾过 慢慢的,由远到近 那满天的乌云好似打翻的墨汁 在天边渲染开来 豆大般的雨点 噼里啪啦...
    BigBosd阅读 278评论 0赞 0
  • 老师,这个冰激凌部分我实在不会涂色,太难了,铅笔稿还好,涂着涂着果然形让我画丢了(橡皮把原稿擦的太干净了),又拿彩...
    寶呗洋洋阅读 347评论 0赞 0

友情链接更多精彩内容