An Android view which provides a nice slide-to-left/right interaction.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 39a3b8a Nov 13, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/images add screenshots Nov 13, 2018
app implement sample app Nov 13, 2018
gradle/wrapper Initial commit Nov 13, 2018
slideactionview started writing sample app Nov 13, 2018
.gitignore Initial commit Nov 13, 2018
LICENSE Create LICENSE Nov 13, 2018
README.md add screenshots Nov 13, 2018
build.gradle Initial commit Nov 13, 2018
gradle.properties Initial commit Nov 13, 2018
gradlew Initial commit Nov 13, 2018
gradlew.bat Initial commit Nov 13, 2018
settings.gradle started writing sample app Nov 13, 2018

README.md

SlideActionView is a simple widget that provides a nice slide-to-left/right interaction. This is a part of my efforts to modularize some of the things that I write; it was originally a part of Alarmio, and has been separated into its own library.

For testing and experimentation purposes, a sample apk can be downloaded here.

Sample App Use in Alarmio
img img

Usage

Setup

This project is published on JitPack, which you can add to your project by copying the following to your root build.gradle at the end of "repositories".

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

To add the dependency, copy this line into your app module's build.gradle file.

implementation 'me.jfenn:SlideActionView:0.0.1'

Basic Use

Adding the SlideActionView somewhere in your layout is fairly simple. Here is an example:

<me.jfenn.slideactionview.SlideActionView
  android:id="@+id/actionView"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_gravity="bottom" />

You will then want to specify icons for the left/right "slides". This can be done using the setLeftIcon and setRightIcon methods of the view. They accept both a Drawable and Bitmap, but it is more efficient to pass a Bitmap if possible.

SlideActionView actionView = findViewById(R.id.actionView);
actionView.setLeftIcon(leftIconBitmap);
actionView.setRightIcon(rightIconBitmap);

In order to listen for the swipe actions, you must implement the SlideActionListener interface.

actionView.setListener(new SlideActionView.SlideActionListener() {
  @Override
  public void onSlideLeft() {
    // slid left
  }
  
  @Override
  public void onSlideRight() {
    // slid right
  }
});

Theming

There are several methods that you can call to specify different colors. I will not go into great detail of what they do, but it should be fairly obvious. setTouchHandleColor changes the color of the touch handle. setOutlineColor affects the outlines. setIconColor changes the filter applied to both icons.