Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexandrius/accordion-swipe-layout
Accordion Swipe Layout for Android
https://github.com/alexandrius/accordion-swipe-layout
Last synced: 3 months ago
JSON representation
Accordion Swipe Layout for Android
- Host: GitHub
- URL: https://github.com/alexandrius/accordion-swipe-layout
- Owner: alexandrius
- Created: 2016-11-21T12:20:28.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-09-20T04:20:23.000Z (about 4 years ago)
- Last Synced: 2024-06-16T02:42:57.594Z (5 months ago)
- Language: Java
- Homepage:
- Size: 193 KB
- Stars: 135
- Watchers: 8
- Forks: 27
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-github-android-ui - accordion-swipe-layout - Android手风琴滑动布局 (滑动删除)
README
# Android Accordion Swipe Layout
### Inspired by iOS Mail app
Easy accordion swipe layout for Android.
Very easy to use
## Step 1
### GradleAdd to root project gradle
```groovy
allprojects {
repositories {
maven {
url "https://jitpack.io"
}
}
}
```Add dependency to app gradle
```groovy
compile 'com.github.alexandrius:accordion-swipe-layout:0.5.0'
```## Step 2
Create main layout for your swipable item.```xml
```
## Step 3
Create array.xml in your values folder
Add custom integer arrays for drawables and swipable item backgrounds### Example:
```xml
@color/color1
@color/color2
@color/color3
@color/color4
@color/color5
@color/color6
@mipmap/ic_reload
@mipmap/ic_settings
@mipmap/ic_trash
@mipmap/ic_reload
@string/reload
@string/settings
@string/trash
```
## Step 4
Add SwipeLayout into your layout```xml
```
### Available attrs:
1. **iconSize**
2. **foregroundLayout** - pass id of previously created layout
3. **leftItemColors**
4. **leftItemIcons**
5. **leftTextColors**
6. **rightTextColors**
7. **rightItemColors**
8. **rightItemIcons**
9. **swipeItemWidth**
10. **leftStrings**
11. **rightStrings**
12. **textSize**
13. **textTopMargin**
14. **customFont**
15. **canFullSwipeFromLeft**
16. **canFullSwipeFromRight**
17. **autoHideSwipe** - automatically collapse item on scroll
18. **onlyOneSwipe** - automatically collapse other item if expanded**canFullSwipeFromLeft** - set swipe to maximum width (like in gif preview) from left. Executes listener for first item
**canFullSwipeFromRight** - set swipe to maximum width (like in gif preview) from right. Executes listener for last item
## Step 5
Add click listener to swipe items
```java
SwipeLayout swipeLayout = (SwipeLayout) findViewById(R.id.swipe_layout);
swipeLayout.setOnSwipeItemClickListener(new SwipeLayout.OnSwipeItemClickListener() {
@Override
public void onSwipeItemClick(boolean left, int index) {
if (left) {
switch (index) {
case 0:
break;
}
} else {
switch (index) {
case 0:
break;
}
}
}
});
```### Expand and collapse programmatically
```java
ITEM_STATE_LEFT_EXPAND
ITEM_STATE_RIGHT_EXPAND
ITEM_STATE_COLLAPSEDswipeLayout.setItemState(SwipeLayout.ITEM_STATE_LEFT_EXPAND, animated);
```
That's pretty much it. Thanks