Skip to content

naseemakhtar994/Custom-Toggle-Button

 
 

Repository files navigation

Custom-Toggle-Button

Download Build Status Android Arsenal codecov Codacy Badge codebeat badge

An android library for outline toggle buttons

unchecked state

checked state

How to use

Include the Library

Add the following lines in your app level dependencies

 dependencies {
        compile 'me.rishabhkhanna:CustomToggle:1.0.0'
    }

Usage

To use Custom toggle button, add the following lines in your xml

    <me.rishabhkhanna.customtogglebutton.CustomToggleButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textOn="toggle button"
        android:textOff="toggle button"
        ></me.rishabhkhanna.customtogglebutton.CustomToggleButton>

Customizations

you can use all the default toggle button attributes and apart from that customizations can be made using following attributes: -

  • app:checkedColor="#333" (To change the color of checked toggle state)
  • app:uncheckedColor="#444" (To change the outline color of unchecked state)
  • app:borderWidth="10dp" (To change border width)
  • app:checkedTextColor="#fff" (To change text color of checked state, Default is #fff)
  • app:uncheckedTextColor="#000" (To change text color of unchecked state, Default is #333)
  • app:radius="10dp" (Define the corner radius of the button, examples given below)

Examples

  • app:radius="0dp"

radius 0dp unchecked radius 0dp checked

  • app:radius="2dp"

radius 2dp unchecked radius 2dp checked

  • app:radius="20dp"

radius 20dp unchecked radius 20dp checked

License

This software is licensed under the Apache License V2.0 A copy can be found here

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%