android加载手势库代码,SwipeBack is 一个可以使用手势完成activity的Android库

SwipeBackLayout

SwipeBackLayout is an android library that can finish an activity by using gesture.

You can set the slide direction,such as FROM_LEFT,FROM_TOP,FROM_RIGHT and FROM_BOTTOM.

You can also set whether it can only slide from the edge.

Screenshots

Custom-Style

WeChat-Style

625332134c6f4d4600884b99daebf603.png

625332134c6f4d4600884b99daebf603.png

Sample Apk Download

Usage

Gradle

dependencies {

compile 'com.gongwen:swipeback:1.0.2'

}

xmlns:app="http://schemas.android.com/apk/res-auto"

android:id="@+id/swipeBackLayout"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:directionMode="left"

app:isSwipeFromEdge="true"

app:maskAlpha="125"

app:swipeBackFactor="0.5">

xmlns:app="http://schemas.android.com/apk/res-auto"

android:id="@+id/swipeBackLayout"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:directionMode="left"

app:isSwipeFromEdge="true"

app:maskAlpha="125"

app:swipeBackFactor="0.5">

Attention: If you are using WxSwipeBackLayout , you must call WxSwipeBackActivityManager.getInstance().init(this) to init it in Application. just like :

public class MainApplication extends Application {

@Override

public void onCreate() {

super.onCreate();

WxSwipeBackActivityManager.getInstance().init(this);

}

}

Attributes

Attribute 属性

Description 描述

swipeBackFactor

set the factor of swipeback

maskAlpha

set the background alpha at the beginning of swipeback

directionMode

set the direction of swiping to finish

isSwipeFromEdge

set whether it can only slide from the edge

public void onCreate(@Nullable Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

//SwipeBackLayout is included in the layout

setContentView(layoutId);

SwipeBackLayout mSwipeBackLayout = (SwipeBackLayout) findViewById(R.id.swipeBackLayout);

mSwipeBackLayout.setDirectionMode(SwipeBackLayout.FROM_LEFT);

mSwipeBackLayout.setMaskAlpha(125);

mSwipeBackLayout.setSwipeBackFactor(0.5f);

mSwipeBackLayout.setSwipeBackListener(new SwipeBackLayout.OnSwipeBackListener() {

@Override

public void onViewPositionChanged(View mView, float swipeBackFraction, float SWIPE_BACK_FACTOR) {

}

@Override

public void onViewSwipeFinished(View mView, boolean isEnd) {

}

});

}

or

public void onCreate(@Nullable Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

SwipeBackLayout mSwipeBackLayout = new SwipeBackLayout(this);

mSwipeBackLayout.addView(contentView);

setContentView(mSwipeBackLayout);

}

or

public void onCreate(@Nullable Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

//SwipeBackLayout is not included in the layout

setContentView(layoutId);

mSwipeBackLayout = new SwipeBackLayout(this);

mSwipeBackLayout.attachToActivity(this);

}

true

@android:color/transparent

Support Views

SwipeBackLayout must contains only one direct child.

Such as:

LinearLayout,RelativeLayout,FrameLayout,TableLayout etc.

ScrollView,HorizontalScrollView,NestedScrollView etc.

RecyclerView,the subClass of AbsListView(ListView etc.)

ViewPager,WebView etc.

reference

License

Copyright (C) 2017 1798550470@qq.com

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值