swipe-button


Source link: https://github.com/ebanx/swipe-button

Swipe-Button

Library of an android button activated by swipe.

  • Easy to use.
  • Makes your app look great
  • Better UX in sensitive button

Installation

compile 'com.ebanx:swipe-button:[latestVersion]' 

How to use

Add the button in your layout file and customize it the way you like it.

<com.ebanx.swipebtn.SwipeButton
  android:id="@+id/swipe_btn"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_marginStart="20dp"
  android:layout_marginEnd="20dp"
  app:inner_text="SWIPE"
  app:inner_text_color="@android:color/white"
  app:inner_text_size="16sp"
  app:inner_text_top_padding="18dp"
  app:inner_text_bottom_padding="18dp"
  app:inner_text_background="@drawable/shape_rounded"
  app:button_image_height="60dp"
  app:button_image_width="100dp"
  app:button_image_disabled="@drawable/ic_lock_open_black_24dp"
  app:button_image_enabled="@drawable/ic_lock_outline_black_24dp"
  app:button_left_padding="20dp"
  app:button_right_padding="20dp"
  app:button_top_padding="20dp"
  app:button_bottom_padding="20dp"
  app:button_background="@drawable/shape_button"
  app:initial_state="disabled"
  app:has_activate_state="true"
  /> 

Setting the sliding button size

You can set the size of the moving part of the button by changing the app:button_image_width and app:button_image_height properties.

Setting the text part size

You can set the size of the fixed part of the button by setting the text size of the setting the padding in this part.

Listening for changes

You can set a listener for state changes

SwipeButton enableButton = (SwipeButton) findViewById(R.id.swipe_btn);
 enableButton.setOnStateChangeListener(new OnStateChangeListener() {

 @Override

  public void onStateChange(boolean active) {

Toast.makeText(MainActivity.this, "State: " + active, Toast.LENGTH_SHORT).show();

 
}
  
}
);
  

Or listen for the activation of the button

swipeButtonNoState.setOnActiveListener(new OnActiveListener() {

 @Override

 public void onActive() {

  Toast.makeText(MainActivity.this, "Active!", Toast.LENGTH_SHORT).show();

 
}

}
);
 

Configure XML

  • button_image_width: Change the width of the moving part of the button
  • button_image_height: Change the height of the moving part of the button
  • inner_text: Text in the center of the button. It disapears when swiped
  • inner_text_color: Color of the text
  • inner_text_size: Size of the text
  • inner_text_[direction]_padding: Sets the padding of the text inside the button. You can set how big this part of the button will by setting text size and padding.
  • button_image_disabled: Icon of the button when disabled. This is the initial state.
  • button_image_enabled: Icon of the button when disabled. This is the initial expanded state.
  • button_[direction]_padding: Sets the padding of the button the slide with the touch. You can set how big the button will be by setting the image and the padding
  • initial_state: Initial state. Default state is disabled.
  • has_activate_state: Set if the button stops in the "active" state. If false, the button will only come back to the initial state after swiped until the end of its way. Use OnActiveListener if you set the parameter to false.
  • button_trail_enabled: Set trailing effect enabled.
  • button_trail_drawable: Set the color of the trailing effect.

CodePen

If you would like to see a front-end version of this button you can check a codepen in this link:

Bugs and features

For bugs, feature requests, and discussion please use GitHub Issues.

Credits

And that's it! Enjoy!

Written with StackEdit.

Resources

TextHighlighter is a simple android API for developers to show highlighted text in android apps, also provides methods to show styled text.

An Android debug / develop tools written using Kotlin language. All the features in Debug bottle are only available on debug build version with your app, it doesn't has an impact on release version.

Simple implementation of ForceTouch on Android

MAHEncryptorLibrary is library for encryption and decryption strings on Android apps and on PC Java applications.

A repository to show how to use some of gradle features.

Here we have some samples and gradle files to be used to help you to automate some tasks for your project.

A gradle task to send files to slack.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes