Android Swipeable button like in iOS unlock screen. Made by Stfalcon

Overview

swipeable-button

Who we are

Need iOS and Android apps, MVP development or prototyping? Contact us via [email protected]. We develop software since 2009, and we're known experts in this field. Check out our portfolio and see more libraries from stfalcon-studio.

Download

Download via Gradle: compile 'com.github.stfalcon:swipeable-button:0.1.0'

Usage

Just put this code into your layout:

<com.stfalcon.swipeablebutton.SwipeableButton
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

You can use many attributes for more flexibility and convenience of use. Here's the full list:

  • isChecked - Initial state. Boolean. False by default
  • isEnabled - Is button enabled. Boolean. True by default
  • textChecked - Text for checked state
  • textUnchecked - Text for unchecked state
  • textColorChecked - Text color when button is checked
  • textColorUnchecked - Text color when button is unchecked
  • textSize - Text size
  • thresholdStart - Value in range [0..1] indicates how much user needs to swipe to change status from unchecked to checked. 0.5 by default
  • thresholdEnd - Value in range [0..1] indicates how much user needs to swipe to change status from checked to unchecked. 0.5 by default
  • checkedBackground - Button background drawable for checked state.
  • uncheckedBackground - Button background drawable for unchecked state.
  • checkedToggleBackground - Toggle background drawable when button is checked.
  • uncheckedToggleBackground - Toggle background drawable when button is unchecked.
  • checkedIcon - Toggle icon drawable when button is checked
  • uncheckedIcon - Toggle icon drawable when button is unchecked

For example:

<com.stfalcon.swipeablebutton.SwipeableButton
    android:id="@+id/customSwipeButton2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="64dp"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    app:checkedBackground="@drawable/shape_sample_scrolling_view_checked"
    app:checkedIcon="@drawable/ic_visible"
    app:checkedToggleBackground="@drawable/shape_sample_checked_toggle"
    app:durationAnimation="250"
    app:isClickToSwipeEnable="false"
    app:thresholdEnd="0.3"
    app:thresholdStart="0.7"
    app:textChecked="@string/checked_state_text"
    app:textColorChecked="@color/checkedTextColor"
    app:textColorUnChecked="@color/uncheckedTextColor"
    app:textSize="8sp"
    app:textUnchecked="@string/unchecked_state_text"
    app:uncheckedBackground="@drawable/shape_sample_scrolling_view_unchecked"
    app:uncheckedIcon="@drawable/ic_usvisible"
    app:uncheckedToggleBackground="@drawable/shape_sample_unchecked_toggle" />

Also you can set them programmatically:

swipeableButton.isChecked = true
swipeableButton.isEnable = true
swipeableButton.checkedText = "Checked text"
swipeableButton.uncheckedText = "Unchecked text"
swipeableButton.textSize = resources.getDimensionPixelSize(R.dimen.default_text_size).toFloat()
swipeableButton.swipeProgressToFinish = 0.1
swipeableButton.swipeProgressToStart = 0.3
swipeableButton.checkedTextColor = ContextCompat.getColor(this,R.color.checkedTextColor)
swipeableButton.uncheckedTextColor = ContextCompat.getColor(this,R.color.uncheckedTextColor)
swipeableButton.checkedBackground = ContextCompat.getDrawable(this, R.drawable.shape_sample_scrolling_view_checked)
swipeableButton.uncheckedBackground = ContextCompat.getDrawable(this, R.drawable.shape_sample_scrolling_view_unchecked)
swipeableButton.checkedToggleBackground = ContextCompat.getDrawable(this, R.drawable.shape_sample_checked_toggle)
swipeableButton.uncheckedToggleBackground = ContextCompat.getDrawable(this, R.drawable.shape_sample_unchecked_toggle)
swipeableButton.checkedIcon = ContextCompat.getDrawable(this, R.drawable.ic_done_black)
swipeableButton.uncheckedIcon = ContextCompat.getDrawable(this, R.drawable.ic_pause_black)

If you want to change the state programmatically with animation you should use setSwipeButtonState method:

animateBtn.setOnClickListener {
   swipeButton.setSwipeButtonState(!swipeableButton.isChecked)
}

If you want to get event from swipable-button you need to add next listeners:

  • onSwipedListener
  • onSwipedOnListener
  • onSwipedOffListener

Let's take look a small sample:

customSwipeButton.onSwipedListener = {
   Log.d(TAG, "onSwiped")
}
customSwipeButton.onSwipedOnListener = {
   Log.d(TAG, "onSwipedOn")
}
customSwipeButton.onSwipedOffListener = {
   Log.d(TAG, "onSwipedOff")
}

License

Copyright 2018 stfalcon.com

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.
You might also like...
Easy social network authorization for Android. Supports Facebook, Twitter, Instagram, Google+, Vkontakte. Made by Stfalcon

SocialAuthHelper A library that helps to implement social network authorization (Facebook, Twitter, Instagram, GooglePlus, Vkontakte). Who we are Need

 Utility for developers and QAs what helps minimize time wasting on writing the same data for testing over and over again. Made by Stfalcon
Utility for developers and QAs what helps minimize time wasting on writing the same data for testing over and over again. Made by Stfalcon

Stfalcon Fixturer A Utility for developers and QAs which helps minimize time wasting on writing the same data for testing over and over again. You can

Screen Capture Utils - A plugin to handle screen capture events on android and ios

Screen Capture Utils A plugin to handle screen capture events on android and ios 🚀 Initialize SDK late ScreenCaptureUtils screenCaptureUtils;

Proof of concept of custom widgets and apps running on the Z Flip3 cover screen. Adds a widget to Z Flip3 cover screen that lets you launch a web browser-like app on the cover.

SubUI-browser Proof of concept of custom widgets and apps running on the Z Flip3 cover screen. Adds a widget to Z Flip3 cover screen that lets you lau

Unlock an Android phone (or device) by bruteforcing the lockscreen PIN.
Unlock an Android phone (or device) by bruteforcing the lockscreen PIN.

Unlock an Android phone (or device) by bruteforcing the lockscreen PIN. Turn your Kali Nethunter phone into a bruteforce PIN cracker for Android devices! (no root, no adb)

A simple 'Slide to Unlock' Material widget for Android, written in Kotlin 📱🎨🦄
A simple 'Slide to Unlock' Material widget for Android, written in Kotlin 📱🎨🦄

Slide To Act A simple Slide to Unlock Material widget for Android, written in Kotlin 🇰. Getting Started Example Features Attributes area_margin inner

A simple 'Slide to Unlock' Material widget for Android, written in Jetpack Compose
A simple 'Slide to Unlock' Material widget for Android, written in Jetpack Compose

SlideTodo A simple 'Slide to Unlock' Material widget for Android, written in Jetpack Compose you can find source code here Getting Started allprojects

LeeCo is an awesome app for (including unlock) problems, solutions, discuss(from leetcode) and comments.
LeeCo is an awesome app for (including unlock) problems, solutions, discuss(from leetcode) and comments.

LeeCo LeeCo is an awesome app for algorithem problems(including unlock), solutions, discuss(from leetcode) and comments. #中文文档 README-ZH.md #Download

The idea of ResideMenu is from Dribbble 1 and 2. It has come true and run in iOS devices. iOS ResideMenu This project is the RefsideMenu Android version. The visual effect is partly referred to iOS version of ResideMenu. And thanks to the authors for the above idea and contribution. Base on android-process-button this is the advanced version of the android-process-button.
Base on android-process-button this is the advanced version of the android-process-button.

Rock Button release log Base on android-process-button this is the advanced version of the android-process-button ##Main Features ActionProcessButton

A simple, customizable and easy to use swipeable view stack for Android.
A simple, customizable and easy to use swipeable view stack for Android.

SwipeStack A simple, customizable and easy to use swipeable view stack for Android. QuickStart Include the Gradle dependency dependencies { compil

A swipeable - auto resizing view group for android
A swipeable - auto resizing view group for android

SwipeableLayout A swipeable - auto resizing view group for android Usage build.gradle compile 'com.wmbest.widget:swipeable-layout:1.0.+@aar' -- or --

CircularCardsStackView is an Android library for dealing with swipeable card views.
CircularCardsStackView is an Android library for dealing with swipeable card views.

CircularCardsStackView Overview Features Android 11 support Easy setup Endless card stack Swipe horizontally with animation Fully customized Support t

SSJetpackComposeSwipeableView is a small library which provides support for the swipeable views
SSJetpackComposeSwipeableView is a small library which provides support for the swipeable views

SSJetpackComposeSwipeableView is a small library which provides support for the swipeable views. You can use this in your lazyColumns or can add a simple view which contains swipe to edit/delete functionality.

A news app made using android studio in Java with features like favourite news, Location detector for local news, and especially made with HUAWEI APIs

HuaweiGlobalNewsApp A news app made using android studio in Java with features like favourite news, Location detector for local news, and especially m

This is an application that is about an X / O game. You can enter the names of the game, and there is also a screen for those who win and there is a button to continue playing and the game determines the result of each player
This is an application that is about an X / O game. You can enter the names of the game, and there is also a screen for those who win and there is a button to continue playing and the game determines the result of each player

Game-X-O This is an application that is about an X / O game. You can enter the names of the game, and there is also a screen for those who win and the

Android-splash-screen-demo - Sample application to demo the various features provided in android-splash-screen
Android-splash-screen-demo - Sample application to demo the various features provided in android-splash-screen

Android Splash screen API demo This is a sample application used to demonstrate the various features provided in android-splash-screen. More details c

Splash screen demo that used with ‘Splash Screen‘ API on Android 12.
Splash screen demo that used with ‘Splash Screen‘ API on Android 12.

Splash Screen Feature Splash screen demo that used with Splash Screen API on Android 12. 📸 Screenshot Default splash screen Splash screen with animat

A dual screen capable home screen launcher for Android phones with dual displays, such as the LG V60, G8X & Velvet.

Duality-Launcher A dual screen capable home screen launcher for Android phones with dual displays, such as the LG V60, G8X & Velvet

Comments
  • Swipe behavior issue

    Swipe behavior issue

    Hi, thanks for the library. Found some issue, thought needs to raise it here to resolve it ASAP. While using the swipeable-button inside the ScrollView or NestedScrollView, It lags and swipe is not working properly. Tested on different devices.

    • Device Specs Mi 11 Lite, Samsung Galaxy J7, Realme X, Mi Note 8 pro.

    • Reproduce Implement ScrollView or NestedScrollView Implement swipeable-button with match_parent width Swipe the button to see the lag.

    opened by sds-dipak 0
  • how to adjust the height of the background equal to that of the button?

    how to adjust the height of the background equal to that of the button?

    I have placed the size tag in the shape of the drawable and I have not achieved the desired effect.

    opened by otonielmax 0
  • Conflict in Attribute name

    Conflict in Attribute name "textSize"

    There's an Issue after I try to replace old swipe button library and adding this library i got the issue of textSize Attribute duplicate. i have attach error image. even after i have remove old library but it keeps giving me this issue. Annotation 2020-06-25 201455

    opened by imkhalid 0
  • unable to set swipe listener

    unable to set swipe listener

    Thanks for the library I am unable to set onSwipe listener for SwipeableButton. I couldn't find any working samples. Can you provide an example please?

    EDIT

    It seems the library is usable only with Kotlin codes. My project is in Java. Is it still possible to use this library?

    opened by itabdullah1 2
Owner
Stfalcon LLC
We specialize in the development of large and medium-sized projects, mobile and web applications, portals with a complex and rich functionality.
Stfalcon LLC
Remoter - An alternative to Android AIDL for Android Remote IPC services using plain java interfaces

Remoter Remoter - An alternative to Android AIDL for Android Remote IPC services using plain java interfaces Remoter makes developing android remote s

Joseph Samuel 68 Dec 16, 2022
Customizable Android full screen image viewer for Fresco library supporting "pinch to zoom" and "swipe to dismiss" gestures. Made by Stfalcon

This project is no longer supported. If you're able to switch from Fresco to any other library that works with the Android's ImageView, please migrate

Stfalcon LLC 1.8k Dec 19, 2022
Customizable Android full screen image viewer for Fresco library supporting "pinch to zoom" and "swipe to dismiss" gestures. Made by Stfalcon

This project is no longer supported. If you're able to switch from Fresco to any other library that works with the Android's ImageView, please migrate

Stfalcon LLC 1.8k Dec 19, 2022
Android library for adding price range with chart like in airbnb with flexible customization. Made by Stfalcon

Stfalcon-PriceRangeBar Demo Application Who we are Need iOS and Android apps, MVP development or prototyping? Contact us via [email protected]. We dev

Stfalcon LLC 223 Nov 25, 2022
Android library to display a few images in one ImageView like avatar of group chat. Made by Stfalcon

MultiImageView Library for display a few images in one MultiImageView like avatar of group chat Who we are Need iOS and Android apps, MVP development

Stfalcon LLC 468 Dec 9, 2022
A package to include a standard Unlock premium view in iOS and Android apps

A package to include a standard Unlock premium view in iOS and Android apps

Groupe MINASTE 2 May 21, 2022
A tinder like swipeable card stack component

AndroidSwipeableCardStack Change log: provide option to infinitly swipe in a loop card rotation setting card gravity setting undo animation Thanks for

wenchao jiang 824 Nov 10, 2022
An Online Meme Sharing app with swipeable vidoes, user can like, share different videos, each viewpager item has one video to show.

MemesSharing An Online Meme Sharing app with swipeable vidoes, user can like, share different videos, each viewpager item has one video to show. 1. Fl

Vikas Bajpayee 13 Aug 6, 2022
🔥 Yet another Tinder like swipeable cards, built for Jetpack Compose

twyper Yet another Tinder like swipeable card library, built for Jetpack Compose ✨ Demo Screen.Recording.2022-02-20.at.10.46.59.PM.mov ⌨️ Usage 1. Add

theapache64 88 Dec 24, 2022
Android library. Flexible components for chat UI implementation with flexible possibilities for styling, customizing and data management. Made by Stfalcon

ChatKit for Android ChatKit is a library designed to simplify the development of UI for such a trivial task as chat. It has flexible possibilities for

Stfalcon LLC 3.6k Jan 5, 2023