Links

GitHub Issues Apache License 2.0 JitPack SlideActionView.apk (0.0.1 stable)

Contributors

fennifith

Slide Action View

git://github.com/fennifith/SlideActionView.git

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.

Last updated: 2018-11-13 17:04:19 +0000

This site may do shady things with cookies and stuff because it's evil. Please don't read my privacy policy. close