Library of an android button activated by swipe.
- Easy to use.
- Makes your app look great
- Better UX in sensitive button
compile 'com.ebanx:swipe-button:[latestVersion]'
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="110dp"
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_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"
/>
You can set the size of the moving part of the button by changing the icon inside it or changing the padding in the button.
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.
You can set a listener for state changes
SwipeButton swipeButton = (SwipeButton) findViewById(R.id.swipe_btn);
swipeButton.setOnStateChangeListener(new OnStateChangeListener() {
@Override
public void onStateChange(boolean active) {
Toast.makeText(MainActivity.this, "State: " + active, Toast.LENGTH_SHORT).show();
}
});
- 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
If you would like to see a front-end version of this button you can check a codepen in this link:
https://codepen.io/gpressutto5/pen/NjJobG
For bugs, feature requests, and discussion please use GitHub Issues.
- Design: Diego Martins
- Development: Leandro Borges Ferreira
- Codepen: Guilherme Pressuto
Written with StackEdit.