Convert Figma logo to code with AI

daimajia logoAndroidSwipeLayout

The Most Powerful Swipe Layout!

12,369
2,672
12,369
383

Top Related Projects

Android滚动选择控件

Side menu with some categories to choose.

You can easily add awesome animated context menu to your app.

CircleProgress, DonutProgress, ArcProgress

Lollipop ViewAnimationUtils.createCircularReveal for everyone 4.0+

:octocat: 📃 FoldingCell is a material design expanding content cell inspired by folding paper material made by @Ramotion

Quick Overview

AndroidSwipeLayout is a popular Android library that provides an easy way to implement swipe-to-reveal functionality in Android applications. It allows developers to create swipeable layouts with customizable actions, enhancing the user interface and interaction in mobile apps.

Pros

  • Easy integration with existing Android projects
  • Highly customizable with various swipe modes and directions
  • Smooth animations and gestures out of the box
  • Extensive documentation and examples provided

Cons

  • May require additional effort to handle complex layouts
  • Performance might be affected when used with large lists
  • Limited built-in support for RTL (Right-to-Left) layouts
  • Some reported issues with nested scrolling in certain scenarios

Code Examples

  1. Basic swipe layout setup:
SwipeLayout swipeLayout = findViewById(R.id.swipe_layout);
swipeLayout.setShowMode(SwipeLayout.ShowMode.PullOut);
swipeLayout.addDrag(SwipeLayout.DragEdge.Left, findViewById(R.id.bottom_wrapper));
  1. Adding swipe listeners:
swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
    @Override
    public void onStartOpen(SwipeLayout layout) {
        // Called when the swipe starts opening
    }

    @Override
    public void onOpen(SwipeLayout layout) {
        // Called when the swipe is fully opened
    }

    // Other listener methods...
});
  1. Programmatically open/close swipe layout:
swipeLayout.open(true); // Open with animation
swipeLayout.close(false); // Close without animation

Getting Started

To use AndroidSwipeLayout in your project, follow these steps:

  1. Add the dependency to your app's build.gradle file:
dependencies {
    implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
}
  1. In your layout XML, use the SwipeLayout as the root view:
<com.daimajia.swipe.SwipeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipe_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    
    <!-- Bottom View (revealed when swiped) -->
    <LinearLayout
        android:id="@+id/bottom_wrapper"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
        <!-- Add your swipe actions here -->
    </LinearLayout>
    
    <!-- Surface View (main content) -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <!-- Add your main content here -->
    </LinearLayout>
</com.daimajia.swipe.SwipeLayout>
  1. In your activity or fragment, initialize and configure the SwipeLayout as shown in the code examples above.

Competitor Comparisons

Android滚动选择控件

Pros of WheelView

  • Specialized for creating wheel-like selection interfaces
  • Customizable appearance with various attributes
  • Lightweight and focused on a single UI component

Cons of WheelView

  • Limited to wheel-style selection, less versatile than SwipeLayout
  • Less actively maintained (last update 7 years ago)
  • Fewer stars and forks, indicating potentially less community support

Code Comparison

WheelView implementation:

WheelView wheelView = (WheelView) findViewById(R.id.wheelview);
wheelView.setItems(Arrays.asList("Item 1", "Item 2", "Item 3"));
wheelView.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
    @Override
    public void onSelected(int selectedIndex, String item) {
        // Handle selection
    }
});

AndroidSwipeLayout implementation:

SwipeLayout swipeLayout = (SwipeLayout)findViewById(R.id.swipe);
swipeLayout.addDrag(SwipeLayout.DragEdge.Left, findViewById(R.id.bottom_wrapper));
swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
    @Override
    public void onStartOpen(SwipeLayout layout) {
        // Handle swipe start
    }
    // Other listener methods...
});

While both libraries provide custom UI components, WheelView focuses on a specific wheel-like selection interface, whereas AndroidSwipeLayout offers more versatile swipe-based interactions. AndroidSwipeLayout has broader applications and more recent updates, making it potentially more suitable for modern Android development. However, if a wheel-style picker is specifically needed, WheelView might be a good choice despite its age.

Side menu with some categories to choose.

Pros of Side-Menu.Android

  • Offers a visually appealing and customizable side menu animation
  • Provides a complete solution for implementing a side menu with minimal setup
  • Includes sample code and a demo app for easy integration

Cons of Side-Menu.Android

  • Limited to side menu functionality, less versatile than AndroidSwipeLayout
  • May require more resources due to complex animations
  • Less actively maintained, with fewer recent updates

Code Comparison

Side-Menu.Android:

ResideMenu resideMenu = new ResideMenu(this);
resideMenu.setBackground(R.drawable.menu_background);
resideMenu.attachToActivity(this);
resideMenu.addMenuItem(menuItem, ResideMenu.DIRECTION_LEFT);

AndroidSwipeLayout:

SwipeLayout swipeLayout = (SwipeLayout)findViewById(R.id.sample1);
swipeLayout.addDrag(SwipeLayout.DragEdge.Left, findViewById(R.id.bottom_wrapper));
swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
    @Override
    public void onStartOpen(SwipeLayout layout) {}
});

Side-Menu.Android focuses on creating a side menu with custom animations, while AndroidSwipeLayout offers more flexibility for various swipe-based interactions. AndroidSwipeLayout provides a wider range of swipe gestures and layouts, making it more versatile for different UI patterns. However, Side-Menu.Android excels in creating polished side menu experiences with less initial setup required.

You can easily add awesome animated context menu to your app.

Pros of Context-Menu.Android

  • Offers a visually appealing circular context menu with smooth animations
  • Provides easy customization options for menu items and appearance
  • Implements a unique and modern UI design that can enhance user experience

Cons of Context-Menu.Android

  • Limited to circular menu layout, which may not suit all app designs
  • Requires more screen space compared to traditional context menus
  • May have a steeper learning curve for implementation due to its unique design

Code Comparison

Context-Menu.Android:

MenuObject close = new MenuObject();
close.setResource(R.drawable.icn_close);
menuObjects.add(close);
mMenuDialogFragment = ContextMenuDialogFragment.newInstance((int) getResources().getDimension(R.dimen.tool_bar_height), menuObjects);

AndroidSwipeLayout:

SwipeLayout swipeLayout = (SwipeLayout)findViewById(R.id.sample1);
swipeLayout.addDrag(SwipeLayout.DragEdge.Left, findViewById(R.id.bottom_wrapper));
swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
    @Override
    public void onClose(SwipeLayout layout) {}
});

Both libraries offer unique UI interactions, with Context-Menu.Android focusing on circular menus and AndroidSwipeLayout providing swipe-based layouts. The choice between them depends on the specific design requirements and user interaction patterns needed for your application.

CircleProgress, DonutProgress, ArcProgress

Pros of CircleProgress

  • Focused on a specific UI element (circular progress indicator)
  • Simpler implementation for circular progress bars
  • Lightweight and easy to integrate into existing projects

Cons of CircleProgress

  • Limited functionality compared to AndroidSwipeLayout's versatile swipe actions
  • Less active development and community support
  • Fewer customization options for complex UI interactions

Code Comparison

CircleProgress:

CircleProgress circleProgress = findViewById(R.id.circle_progress);
circleProgress.setProgress(75);
circleProgress.setMaxValue(100);
circleProgress.setProgressColor(Color.BLUE);
circleProgress.setProgressBackgroundColor(Color.GRAY);

AndroidSwipeLayout:

SwipeLayout swipeLayout = findViewById(R.id.swipe_layout);
swipeLayout.addDrag(SwipeLayout.DragEdge.Left, findViewById(R.id.bottom_wrapper));
swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
    @Override
    public void onStartOpen(SwipeLayout layout) {
        // Handle swipe start
    }
    // ... other listener methods
});

The code comparison shows that CircleProgress is more straightforward for implementing circular progress indicators, while AndroidSwipeLayout offers more complex swipe interactions and event handling. CircleProgress focuses on customizing the appearance and progress of a circular bar, whereas AndroidSwipeLayout provides methods for adding drag edges and swipe listeners for interactive layouts.

Lollipop ViewAnimationUtils.createCircularReveal for everyone 4.0+

Pros of CircularReveal

  • Focuses on a specific animation effect (circular reveal), providing a polished and targeted solution
  • Supports both pre-Lollipop and Lollipop+ devices, ensuring wider compatibility
  • Lightweight and easy to integrate into existing projects

Cons of CircularReveal

  • Limited to circular reveal animations, less versatile than AndroidSwipeLayout
  • May require additional customization for complex UI interactions
  • Less actively maintained, with fewer recent updates compared to AndroidSwipeLayout

Code Comparison

CircularReveal:

ViewAnimationUtils.createCircularReveal(
    view,
    centerX, centerY,
    startRadius, endRadius
).start();

AndroidSwipeLayout:

SwipeLayout swipeLayout = (SwipeLayout)findViewById(R.id.sample1);
swipeLayout.addDrag(SwipeLayout.DragEdge.Left, findViewById(R.id.bottom_wrapper));
swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
    // Implement listener methods
});

CircularReveal provides a simple API for creating circular reveal animations, while AndroidSwipeLayout offers more complex swipe interactions with customizable drag edges and listeners. AndroidSwipeLayout is more suitable for creating interactive UI elements with swipe gestures, whereas CircularReveal excels at creating visually appealing reveal animations for view transitions or content loading effects.

:octocat: 📃 FoldingCell is a material design expanding content cell inspired by folding paper material made by @Ramotion

Pros of folding-cell-android

  • Offers a unique folding animation effect, providing a visually appealing transition
  • Supports customizable content for both folded and unfolded states
  • Includes a demo app with multiple examples for easy implementation

Cons of folding-cell-android

  • Limited to a specific folding animation, less versatile than swipe layouts
  • May require more complex view hierarchies to achieve desired effects
  • Less actively maintained compared to AndroidSwipeLayout

Code Comparison

folding-cell-android:

val foldingCell = findViewById<FoldingCell>(R.id.folding_cell)
foldingCell.setOnClickListener {
    foldingCell.toggle(false)
}

AndroidSwipeLayout:

SwipeLayout swipeLayout = findViewById(R.id.swipe_layout);
swipeLayout.addDrag(SwipeLayout.DragEdge.Left, findViewById(R.id.bottom_wrapper));
swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
    // Implement listener methods
});

Both libraries offer unique UI interactions, with folding-cell-android focusing on a specific folding animation effect, while AndroidSwipeLayout provides more versatile swipe gestures. The choice between them depends on the desired user experience and specific project requirements.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Android Swipe Layout Build Status

![Gitter](https://badges.gitter.im/Join Chat.svg)

Insight.io

This is the brother of AndroidViewHover.

One year ago, I started to make an app named EverMemo with my good friends. The designer gave me a design picture, the design like this:

I found it was pretty hard to achieve this effect, cause you had to be very familiar with the Android Touch System. It was beyond my ability that moment, and I also noticed that there was no such a concept library...

Time passed, finally...as you see right now.

Demo

Download Demo

Before I made this, I actually found some libraries (eg.SwipeListView) that helps developers to integrate swiping with your UI component.

But it only works in ListView, and it has too many issues that they never care. What a pity!

When I start to make this library, I set some goals:

  • Can be easily integrated in anywhere, ListView, GridView, ViewGroup etc.
  • Can receive onOpen,onClose,onUpdate callbacks.
  • Can notifiy the hidden children how much they have shown.
  • Can be nested each other.
  • Can handle complicate situation, just like this.

Usage

Step 1

Gradle

dependencies {
    compile 'com.android.support:recyclerview-v7:21.0.0'
    compile 'com.android.support:support-v4:20.+'
    compile "com.daimajia.swipelayout:library:1.2.0@aar"
}

Maven

<dependency>
	<groupId>com.google.android</groupId>
	<artifactId>support-v4</artifactId>
	<version>r6</version>
</dependency>
<dependency>
	<groupId>com.google.android</groupId>
	<artifactId>recyclerview-v7</artifactId>
	<version>21.0.0</version>
</dependency>
<dependency>
    <groupId>com.daimajia.swipelayout</groupId>
    <artifactId>library</artifactId>
    <version>1.2.0</version>
    <type>apklib</type>
</dependency>

Eclipse

AndroidSwipeLayout-v1.1.8.jar

Step 2

Make sure to use the internal adapter instead of your own!

Wiki Usage

Wiki

Go to Wiki

About me

A student in mainland China.

Welcome to offer me an internship. If you have any new idea about this project, feel free to contact me. :smiley: