liuguangqiang / swipeback Goto Github PK
View Code? Open in Web Editor NEWSwipeBack is an android library that can finish a activity by using gesture.
License: Apache License 2.0
SwipeBack is an android library that can finish a activity by using gesture.
License: Apache License 2.0
when a baiduMapView on SwipeBacklayout,it will show after i swipeback.it will disappear for a moment then show it's self about 1 second,at last it'll disapper....
how can i solve this?
Thank you for share library
I have problem with Fragment.
Could you help me support for swipe on fragment ?
I saw check this library: https://github.com/ikew0ng/SwipeBackLayout
but it don't tap and swipe on middle screen like your library
my activity extends Activity and in the layout xml hava a webview ,but it can not scroll.
When i was swiping left the activity, the background was blank until complete close of swipe activity.But i want to show background activity on swipe.Any help ??
Hi, Thank you for the awesome library. I am struck with a problem. I've an activity layout on which I've a banner and than details which are scrollable. The banner is fixed here while details can scroll. Now what I want is that when user touches the banner and swipes down than the activity shoud close otherwise if the details section is touched, it should scroll.
Everything works perfectly fine, but the only problem is when I scroll exactly at the bottom, take my finger off of the screen and now touch it again to scroll back up. It starts dragging the activity down instead of scrolling ( note here I am touching the details section, not the banner ), but if the scroll is not at the bottom and I repeat the same procedure, the scrolling works fine.
This has happened to me with another library where I happened to debug the files. The onTouchEvent
of the library was called only when I repeat the above procedure and once it is called than the scrollview stopped working.
I hope I was able to explain it properly. Let me know if you've questions. I have been stuck on this since very long. Any help will be appreciated.
hi
thank you for this library
how can i use it with dialog fragment
i put SwipeBackLayout as parent and put other things in it
when i call dialog , after swiping app crashes with android.view.ContextThemeWrapper cannot be cast to android.app.Activity
can you please tell me how to use it with dialog fragment?
thank you very much
The ActionBarActivity, extended into SwipeBackActivity, is deprecated on SDK versione 26.
Not compile
it must be replaced with AppCompatActivity
Hi. Your library is good. But one problem i have found. Animation of closing common activity in your screen is correct, but in my phone i can't see the activity which is under of this.
Here is the screen
https://yadi.sk/i/WeM-j_Pw3F87Qt
I want using libs in fragment. ??
I tried to add my own icon to my app in Android Studio and I encountered a Manifest merger fail. I fount an identical question here but his answer is not working for me. I tried adding tools:replace="android:icon" and tools:replace="android:icon,android:theme" (on 2 separate occasions of course) but no change. Can you remove the launcher icon from the library's manifest ?
无法禁止向下滑动
I tried to change the swipe direction to left only. But when i scroll down in my nestedscrollview with textviews my activity gets closed to bottom. Any ideas?
I am getting this white screen attached below for some time like around 3 seconds when I swipe left to right so can you help me how to remove that, i want when i swipe left to right i want to display my previous activity directly instead of showing this white screen.
Also, can you help me how to reduce the time between this two activity transactions?
Current implementation Interrupts the view pager's slidder functionality, I want the swipe to enable only for some specific angles(85 to 95 & 265 to 275).
Add two swipe directions,right and bottom.
When creating an activity using the SwipeBack theme, the aplication crashes with the following error:
java.lang.IllegalArgumentException: AppCompat does not support the current theme features: { windowActionBar: false, windowActionBarOverlay: false, android:windowIsFloating: false, windowActionModeOverlay: false, windowNoTitle: false
Presumably, as a result, swiping back does not show the activity behind it but instead fades it in after the animation completes.
how to set the trigger zone
测试发现,如果代码中存在listview等可滚动控件,且没有放到布局代码的第一层(如下即为放到第一层)
会存在滑动冲突问题,然而实际应用中,布局肯定十分复杂,很难直接放于第一层
研究源码发现代码中有这样一个方法 findScrollView,是用来寻找布局中可滚动的控件,但仅找了第一层,所以会出现以上问题
尝试将该方法改为递归后解决问题:即从整个布局代码中寻找滚动控件,但如果布局中存在多个滚动控件的话,可能会出问题
代码如下
private View findScrollView(ViewGroup viewGroup) {
View child = viewGroup;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
child = viewGroup.getChildAt(i);
if (child instanceof AbsListView || child instanceof ScrollView || child instanceof ViewPager || child instanceof WebView) {
return child;
} else if (child instanceof ViewGroup) {
child = findScrollView((ViewGroup) child);
if (child instanceof AbsListView || child instanceof ScrollView || child instanceof ViewPager || child instanceof WebView) {
return child;
} else {
continue;
}
} else {
continue;
}
}
return child;
}
I only want to trigger the Swipeback on the header (specific View) of the Activity. How can I do this?
PagerSlidingTabStrip 可以左右滑动
但如果设置了setDragEdge(SwipeBackLayout.DragEdge.LEFT);
导致PagerSlidingTabStrip向右划就失效了
可否根据用户第一次按下的位置来区分 到底是PagerSlidingTabStrip的切换 or SwipeBackAcitivy的退出?
private void chkDragable() {
setOnTouchListener(new View.OnTouchListener() {
@OverRide
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
lastY = motionEvent.getRawY();
lastX = motionEvent.getRawX();
} else if (motionEvent.getAction() == MotionEvent.ACTION_MOVE) {
newY = motionEvent.getRawY();
---------------------"lastX = motionEvent.getRawX();"------------------------
offsetY = Math.abs(newY - lastY);
lastY = newY;
offsetX = Math.abs(newX - lastX);
lastX = newX;
switch (dragEdge) {
case TOP:
case BOTTOM:
setEnablePullToBack(offsetY > offsetX);
case LEFT:
case RIGHT:
setEnablePullToBack(offsetY < offsetX);
break;
}
}
return false;
}
});
}
}
标注的地方, 应该是
newX = motionEvent.getRawX();
但是修改之后, 拖拽就失效了
It will look good if we add a multipler to slider. If the user need slide to 50% of screen, the scroll need to be on bottom screen.
Look like (ideia):
View.setY(fingerPosition.getY/multipler);
Need more help? Contact me: [email protected] or on Hangouts: [email protected]
Hello
I am using swipe back activity in one of my project activity. My activity layout contains recyclerview and other components as well. So the problem is when I scroll up my recyclerview items then activity get finished.
So is there any way to prevent activity to finish while recyclerview is visible ?
I checked both version (0.1.0 and 0.3.0), SwipeBackActivity is not there.
1.设置左滑之后,下滑禁止不掉
这个问题是因为你的Activity即继承了SwipeBackActivity,Activity的布局中又加上了SwipeBackLayout。解决办法是要么继承SwipeBackActivity,然后在onCreate直接setDragEdge()设置;要么再布局文件中加上SwipeBackLayout,然后在Activty里调用SwipeBackLayout的setDragEdge()方法;两者只能选一个。
2.Activity中有webview或者ListView、Recyclerview等可以上下拖动的控件时,侧滑很容易被触发。
这个问题是滑动冲突照成的,位于底部的SwipeBackLayout拦截了子View的触摸事件。所以我们要做的是继承SwipeBackLayout重写它的onInterceptTouchEvent()方法,当手指在Y轴的移动速度大于X轴的移动速度时不拦截这个触摸事件,代码如下:
public class MySwipeBackLayout extends SwipeBackLayout{
private float startY;
private float startX;
// 记录viewPager是否拖拽的标记
private boolean mIsVpDragger;
private int mTouchSlop;
public MySwipeBackLayout(Context context) {
super(context);
}
public MySwipeBackLayout(Context context, AttributeSet attrs) {
super(context, attrs);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
setDragEdge(DragEdge.LEFT);
}
@OverRide
public boolean onInterceptTouchEvent(MotionEvent ev) {
int action = ev.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// 记录手指按下的位置
startY = ev.getY();
startX = ev.getX();
// 初始化标记
mIsVpDragger = false;
break;
case MotionEvent.ACTION_MOVE:
// 如果viewpager正在拖拽中,那么不拦截它的事件,直接return false;
if(mIsVpDragger) {
return false;
}
// 获取当前手指位置
float endY = ev.getY();
float endX = ev.getX();
float distanceX = Math.abs(endX - startX);
float distanceY = Math.abs(endY - startY);
// 如果X轴位移大于Y轴位移,那么将事件交给viewPager处理。
/if(distanceX > mTouchSlop && distanceX > distanceY) {
mIsVpDragger = true;
return false;
}/
if(distanceY > mTouchSlop && distanceY > distanceX) {
mIsVpDragger = true;
return false;
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
// 初始化标记
mIsVpDragger = false;
break;
}
// 如果是Y轴位移大于X轴,事件交给SwipeBackLayout处理。
return super.onInterceptTouchEvent(ev);
}
}
3.布局中有个viewpager或者横向的recyclerview时,向右滑触发SwipeBackLayout侧滑。
这也是滑动冲突照成的,我们要做的是重写viewpager或recyclerview的dispatchTouchEvent()方法。
代码如下:
public class MyRecyclerView extends RecyclerView{
public MyRecyclerView(Context context) {
super(context);
}
public MyRecyclerView(Context context, @nullable AttributeSet attrs) {
super(context, attrs);
}
public MyRecyclerView(Context context, @nullable AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@OverRide
public boolean dispatchTouchEvent(MotionEvent ev) {
if (getParent() != null){
getParent().requestDisallowInterceptTouchEvent(true);
}
return super.dispatchTouchEvent(ev);
}
}
While swiping BOTTOM the parent activity should be transparent instead of showing blank view, How can I achieve that?
如题
如何不设置Activity为透明
when i swipe left to right not in single line, activity can swipe to close, but i don't like that, i would line to swipe for example left to right on single line directly, how can fix this problem?
不知道为何,有时点A界面上的按钮,就跳转不到B界面上了,这样的概率也蛮大的
What are the necessary proguard rules for this library?
Running into the following when building with minifyEnabled true.
Warning:com.liuguangqiang.swipeback.SwipeBackActivity: can't find superclass or interface android.support.v7.app.ActionBarActivity
Warning:com.liuguangqiang.swipeback.SwipeBackActivity: can't find referenced class android.support.v7.app.ActionBarActivity
Warning:com.liuguangqiang.swipeback.SwipeBackActivity: can't find referenced method 'android.content.res.Resources getResources()' in program class com.liuguangqiang.swipeback.SwipeBackActivity
Warning:com.liuguangqiang.swipeback.SwipeBackActivity: can't find referenced class android.support.v7.app.ActionBarActivity
我需要仅仅通过纯左右滑动,也就是只有x值,y值不变,才判定为要退出界面,请教要如何设置?
I've found a problem: If the developer add 2 multi views and hide or show this view, or I need set the archor to another view, the sliding of View not work good.
It will be cool if it will be possible to adjust the sensitivity. A swipe is also simultaneously in different directions, for example DragEdge.VERTICAL and DragEdge.HORIZONTAL.
When use this with databinding, RuntimeException occured.
I am getting errors building with the latest AppCompat library.
Error:(40, 8) error: cannot access ActionBarActivity
class file for android.support.v7.app.ActionBarActivity not found
I am importing the library properly
compile 'com.github.liuguangqiang.swipeback:library:1.0.2@aar'
public class ViewPagerActivity extends SwipeBackActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_viewpager);
initViews();
setDragEdge(SwipeBackLayout.DragEdge.TOP);
}
private void initViews() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.title_activity_viewpager);
toolbar.setTitleTextColor(Color.WHITE);
setSupportActionBar(toolbar);
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_demo);
TestAdapter adapter = new TestAdapter(getSupportFragmentManager());
viewPager.setAdapter(adapter);
}
}
试了一下ViewDragHelper.create修改感觉效果也不是很好
Hola! @pmaingi has created a ZenHub account for the liuguangqiang organization. ZenHub is the leading team collaboration and project management solution built for GitHub.
To get set up with ZenHub, all you have to do is download the browser extension and log in with your GitHub account. Once you do, you’ll get access to ZenHub’s complete feature-set immediately.
ZenHub adds a series of enhancements directly inside the GitHub UI:
Still curious? See more ZenHub features or read user reviews. This issue was written by your friendly ZenHub bot, posted by request from @pmaingi.
Hi, I want to start specific activity when user swipeback. how can i do it?
tnx
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.