内容简介:由于个人是左撇子,用左手玩手机居多,刷掘金的时候,因为掘金的侧滑退出的范围是在太大,个人手机x轴上触发范围超过200px,上下滑动详情界面,经常同时触发滑动回退,实讲,体验非常差。1.定位代码位置掘金用了乐加固,直接用apktool无法解出来,脱壳之类的操作,我也还没接触过,所以这里直接在xposed上找了个直接可以更改应用为调试模式(android:debuggable="true")的插件,然后使用androidstudio自带的 Profiler的cup板块,录制一个执行(我的手机还是7.0)
由于个人是左撇子,用左手玩手机居多,刷掘金的时候,因为掘金的侧滑退出的范围是在太大,个人手机x轴上触发范围超过200px,上下滑动详情界面,经常同时触发滑动回退,实讲,体验非常差。
操作
1.定位代码位置
掘金用了乐加固,直接用apktool无法解出来,脱壳之类的操作,我也还没接触过,所以这里直接在xposed上找了个直接可以更改应用为调试模式(android:debuggable="true")的插件,然后使用androidstudio自带的 Profiler的cup板块,录制一个执行(我的手机还是7.0)
搜索事件相关的几个方法,因为这个滑动事件是在onTouchEvent中处理的,所以我们可以通过onInterceptTouchEvent来控制拦截(如果用dispatchTouchEvent来处理滑动事件,就不太好弄了~)
2.xposed 大法
Class c = XposedHelpers.findClass("im.juejin.android.base.views.swipebacklayout.SwipeBackLayout"
, lpparam.classLoader);
XposedHelpers.findAndHookMethod(c, "onInterceptTouchEvent",
MotionEvent.class
, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (param != null && param.args[0] instanceof MotionEvent) {
// 获取onInterceptTouchEvent的参数
MotionEvent me = (MotionEvent) param.args[0];
// thisObject就是SwipeBackLayout也就是View,所以这里直接通过getContext获取context
Context context = ((View) param.thisObject).getContext();
if (me.getX() < ViewConfiguration.get(context).getScaledEdgeSlop()) {
super.afterHookedMethod(param);
return;
}
}
param.setResult(false);
})
复制代码
通过以上代码也就简单的实现缩小侧滑触发范围的功能。
终语
其实也向掘金提出过这个侧滑的问题,当然到目前为止的版本都没有调整,这里操作只是为了方便个人的使用。
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- SlidingMenu实现侧滑效果
- iOS侧滑菜单-完全解耦-一行调用
- Android之自定义View:侧滑删除
- 给你的页面带上侧滑返回——SlideBack
- MaterialDrawer 6.0.0 发布,Android 侧滑显示控件
- MaterialDrawer 6.1.1 发布,Android 侧滑显示控件
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Big Java Late Objects
Horstmann, Cay S. / 2012-2 / 896.00元
The introductory programming course is difficult. Many students fail to succeed or have trouble in the course because they don't understand the material and do not practice programming sufficiently. ......一起来看看 《Big Java Late Objects》 这本书的介绍吧!