Giter VIP home page Giter VIP logo

slidingbutton's Introduction

SlidingButton

Min SDK Version

Slide button library for android, we hope this library is useful and easy to customize as you needed. For additional information you can see change log

Sample Preview

Sample A

Preview A-1

Preview A-2

Preview A-3

Preview A-4

Sample B

Preview B-1

Preview B-2

Preview B-3

Preview B-4


Gradle

Add dependencies to your build.gradle file at :app or modules level

implementation 'id.ss564.lib.slidingbutton:slidingbutton:<latest-version>'

and don't forget add jcenter() to your repository

repositories {
    //...
    jcenter()
    //...
}

Then sync your gradle.


How To Use

Notes : This guide is still in process, I will work on it as soon as possible. So, keep checking later if you see this note.

In your layout.xml file, add the view

<id.ss564.lib.slidingbutton.SlidingButton
    android:id="@+id/slidingButton"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

Yeah... just add like code above. It's pretty simple ๐Ÿ˜„

You can use SlidingButton.OnStateChangeListener to find out if the button is shifted or not. Just add a little bit code like below on your java or kotlin file, for example on MainActivity

  • Java
public class MainActivity extend AppCompatActivty {
    
    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        SlidingButton mSlidingButton = findViewById(R.id.slidingButton);
        mSlidingButton.setOnStateChangeListener(new SlidingButton.OnStateChangeListener(){
            
            @Override
            public void onChange(boolean active){
                //do what you wanna to do
            }
        })
    }
}
  • Kotlin
class MainActivity : AppCompatActivity() {
    
    override fun onCreate(savedInstanceState : Bundle?){
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        
        //access view using synthetic, do your own style to access the view :)
        slidingButton.setOnStateChangeListener { active ->
	    //or using `object : SlidingButton.OnStateChangeListener` instead of lambda
	    
	    //do what you wanna to do
        }
    }
}

It's pretty simple right? ๐Ÿ˜„

If you wanna customizing, please attention to the following attributes:

  • app:sliding_text

    Use to set text to the view, value of this attribute is string that can be hardcode, reference,or null

  • app:sliding_text_color

    Use to set text color, value of this attribute can be hardcode or reference. Absolutely you can reference it to ColorStateList ๐Ÿ˜„

  • app:sliding_text_size

    Use to set text size, value of this attribute is dimension that can be hardcode or reference

  • app:sliding_text_fontFamily

    Use to set font family by name, value of this attribute is string that can be hardcode, or reference

  • app:sliding_text_textStyle

    Use to set text style, value of this attribute normal, italic,bold, or bold|italic

  • app:sliding_text_background

    Use to set text background, value of this attribute can be color, drawable, or null. Absolutely you can reference it to ColorStateList or StateListDrawable ๐Ÿ˜„

  • app:sliding_text_paddingStart, app:sliding_text_paddingTop, app:sliding_text_paddingEnd, app:sliding_text_paddingBottom

    Use to set text padding, value is dimension that can be hardcode or reference

  • app:sliding_button_width, app:sliding_button_height

  • app:sliding_button_icon

  • app:sliding_button_icon_tint

  • app:sliding_icon_scaleType

  • app:sliding_button_background

  • app:sliding_button_paddingStart, app:sliding_button_paddingTop, app:sliding_button_paddingEnd, app:sliding_button_paddingBottom

  • app:sliding_button_marginStart, app:sliding_button_marginTop, app:sliding_button_marginEnd, app:sliding_button_marginBottom

  • app:sliding_enabledTextAlpha

    Use to alpha text when sliding, value of this attribute Boolean. Default value true

  • app:sliding_showTrack

    Use to show track indicator when sliding, value of this attribute Boolean. Default value false

  • app:sliding_trackBackground

    Use to set track indicator background.

  • app:sliding_trackBackgroundTint

    Use to set tint track indicator background.

  • app:sliding_trackExtendTo

    Use to set track extended to container or button

  • app:sliding_corner_radius only on API level 21 (Lollipop)


License

MIT License

Copyright (c) 2020 Source Set 564 Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

slidingbutton's People

Contributors

nuarz71 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

slidingbutton's Issues

The sliding button is not always responsive

Unresponsive sliding button
While making use of the sliding button, I noticed that most times when I try sliding, it just stops at some point. It can be at the middle or something, it doesn't go all the way to the end most times.

Screenshots
image

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.