Coder Social home page Coder Social logo

custombutton's Introduction

Android CustomButton v1.0.0

This is an Android library. When we use the Buttons in Andrlid, we may write XML files to make the button become beautiful, it's very tired. You can use this library to easily make beautiful buttons. There is also provided a ripple effect button, which is so cool.

Screenshots

screenshot_0

Usage

Step 1

####Gradle

dependencies {
    compile 'com.github.whilu.CustomButton:library:1.0.0'
}

If it doesn't work, please send me an email.

Step 2

First, add the namespace in the XML file:

xmlns:whilu="http://schemas.android.com/apk/res-auto"

Then, you can easily use it:

1.CustomImageButton, no need to write a xx_selector.xml, just add the value.

<com.github.whilu.library.CustomImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="fitCenter"
    whilu:unpressed_src="@drawable/ic_btn_go_menu"
    whilu:pressed_src="@drawable/ic_btn_go_menu_pressed" />
  • whilu:unpressed_src (the drawable before the ImageButton pressed)
  • whilu:pressed_src (the drawable when the ImageButton pressed)

It looks like this:

screenshot_1

2.CustomButton

<com.github.whilu.library.CustomButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Custom Button"
    whilu:shape_type="rectangle"
    whilu:round_radius="10dp"
    whilu:pressed_color="@color/pressed_color_s2"
    whilu:unpressed_color="@color/unpressed_color_s2" />
  • whilu:shape_type (the shape of the Button, provided circle and rectangle)
  • whilu:round_radius (the round corner radius of the Button)
  • whilu:pressed_color (the color when the Button pressed)
  • whilu:unpressed_color (the color before the Button pressed)

It looks like this:

No round corner

screenshot_2

With round corner

screenshot_3

If you use CustomButton with circle shape, you need to define an accurate value for android:layout_width and android:layout_height. Generally, they are equal.

It looks like this:

screenshot_4

3.CustomRippleButton

<com.github.whilu.library.CustomRippleButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Custom RippleButton"
    whilu:ripple_color="@color/unpressed_color_s2"
    whilu:ripple_duration="500"
    whilu:shape_type="rectangle"
    whilu:round_radius="10dp"
    whilu:unpressed_color="@color/unpressed_color_s" />
  • whilu:ripple_color (the ripple effect color)
  • whilu:ripple_duration (the ripple eccect duration time[ms])
  • whilu:shape_type (the shape of the Button, provided circle and rectangle)
  • whilu:round_radius (the round corner radius of the Button)
  • whilu:unpressed_color (the color before the Button pressed)

It looks like this:

No round corner

screenshot_5

With round corner

screenshot_6

If you use CustomRippleButton with circle shape, you need to define an accurate value for android:layout_width and android:layout_height. Generally, they are equal.

It looks like this:

screenshot_7

SAMPLE

sample apk

About

If you have any problems, please email me.

License

Copyright 2015 whilu

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

custombutton's People

Contributors

whilu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.