• Stars
    star
    487
  • Rank 90,352 (Top 2 %)
  • Language
    Java
  • Created over 5 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Android 侧划,如斯优雅

SwipePanel(侧划控件)

Background

对市面上实现的侧划返回不是很满意(仿微信,QQ 通过修改窗口透明坑太多),最终决定还是亲手写一个高实用性的吧,效果如下所示,换个图标,更多划动功能可以由你自己解锁,总共一个 600 多行代码的类,推荐通过阅读源码,你肯定会收获很多哈。

Preview

layout back

Download

Gradle:

implementation 'com.blankj:swipe-panel:1.2'

How to use

动态

final SwipePanel swipePanel = new SwipePanel(this);
swipePanel.setLeftEdgeSize(SizeUtils.dp2px(100));// 设置左侧触发阈值 100dp
swipePanel.setLeftDrawable(R.drawable.base_back);// 设置左侧 icon
swipePanel.wrapView(findViewById(R.id.rootLayout));// 设置嵌套在 rootLayout 外层
swipePanel.setOnFullSwipeListener(new SwipePanel.OnFullSwipeListener() {// 设置完全划开松手后的监听
    @Override
    public void onFullSwipe(int direction) {
        finish();
        swipePanel.close(direction);// 关闭
    }
});

静态

<com.blankj.swipepanel.SwipePanel
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/swipePanel"
        android:background="@color/mediumGray"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".LayoutSwipePanelActivity"
        app:isLeftCenter="false"
        app:leftEdgeSize="100dp"
        app:leftSwipeColor="@color/colorPrimary"
        app:leftDrawable="@drawable/base_back">

    ...

</com.blankj.swipepanel.SwipePanel>

API

方法名 属性名 说明
setLeft(Top, Right, Bottom)SwipeColor app:left(top, right, bottom)SwipeColor 设置左(上、右、下)侧颜色
setLeft(Top, Right, Bottom)EdgeSize app:left(top, right, bottom)EdgeSize 设置左(上、右、下)侧触发阈值
setLeft(Top, Right, Bottom)Drawable app:left(top, right, bottom)Drawable 设置左(上、右、下)侧 icon
setLeft(Top, Right, Bottom)Center app:isLeft(Top, Right, Bottom)Center 设置左(上、右、下)侧是否居中
setLeft(Top, Right, Bottom)Enabled app:isLeft(Top, Right, Bottom)Enabled 设置左(上、右、下)侧是否可用
wrapView --- 设置嵌套在该 view 的外层
setOnFullSwipeListener --- 设置完全划开松手后的监听
setOnProgressChangedListener --- 设置进度变化的监听
isOpen --- 判断是否被划开
close --- 关闭

Change Log

打个小广告

欢迎加入我的小专栏「基你太美」一起学习。

More Repositories

1

AndroidUtilCode

🔥 Android developers should collect the following utils(updating).
Java
33,174
star
2

awesome-java-leetcode

👑 LeetCode of algorithms with java solution(updating).
Java
8,683
star
3

AndroidStandardDevelop

🌟 Best practices in Android develop(final).
2,998
star
4

awesome-comment

💥 Funny comments
2,321
star
5

AndroidOfferKiller

💪 Help you get a better offer.
1,846
star
6

FreeProGuard

🔰 Config proguard for common Android libraries.
Java
562
star
7

resume

🎉 An resume template for Android developers.
CSS
499
star
8

ALog

📝 A simple util of log in Android develop.
Java
450
star
9

RxBus

🚌 The RxBus as steady as an old dog.
Java
342
star
10

AucFrameTemplate

AucFrame
Groovy
255
star
11

ProgressRing

自定义View之渐变圆环进度条
Java
157
star
12

doge-expression

🐶 Expression of cartoon doge
139
star
13

HelloKotlin

💨 Kotlin从入门到JAVA
80
star
14

glory

select * from learn
CSS
36
star
15

NiceViewPager

Java
25
star
16

proguard-templates

24
star
17

blankj.github.io

homepage
HTML
22
star
18

AutoCheckEditTextDemo

Automatically check user's input is correct.
Java
17
star
19

AchieveScroll

Java
15
star
20

RecyclerPopupWindow

Use RecyclerView and PopupWindow to Replace ListPopupWindow
Java
15
star
21

StaticBus

🚌 A static bus use in modules.
Java
15
star
22

Blankj

About me
11
star
23

GetRotateDegree

Java
10
star
24

EditTextPassword

Java
10
star
25

AndroidUtilDebug

7
star
26

AndroidStudioGitIgnore

Android Studio .gitignore
6
star
27

CustomViewGroup

Java
5
star
28

AndroidCommon

Java
5
star
29

AppFrame

Java
5
star
30

RewriteView

Java
4
star
31

MyTopBar

Java
3
star
32

ListViewExpandation

Java
3
star
33

GoGoGo

3
star
34

ListViewSkill

Java
2
star
35

EventIntercept

Java
2
star
36

JavaUtilCode

1
star
37

AndroidStudioPluginTemplate

1
star
38

Lg

二次封装mars-xlog
C++
1
star
39

AndroidStudioTemplatePlugin

1
star