SlidingUpPanel的使用
来源:互联网 发布:正当防卫3优化怎么样 编辑:程序博客网 时间:2024/05/16 18:57
下载地址:https://github.com/umano/AndroidSlidingUpPanel
最近项目中使用过这种控件,调用的方法expandPanel(float offset);该方法主要设置打开的程度。以此,在背景处并不能响应点击事件,从而使得这个控件收拢,看了看这个View的事件处理方法中,从而获知,其中有一个方法:
private boolean isDragViewUnder(int x, int y) {
View dragView = mDragView != null ? mDragView : mSlideableView;
if (dragView == null)
return false;
int[] viewLocation = new int[2];
dragView.getLocationOnScreen(viewLocation);
int[] parentLocation = new int[2];
this.getLocationOnScreen(parentLocation);
int screenX = parentLocation[0] + x;// 0
int screenY = parentLocation[1] + y;// 113
return screenX >= viewLocation[0]&& screenX < viewLocation[0] + dragView.getWidth()
&& screenY >= viewLocation[1]
&& screenY < viewLocation[1] + dragView.getHeight();
}
通过各种点击,各种Log数据统计,发现该方法是计算一个范围,也就是类似于SlidingUpPanelLayout的底部View的,也就是第二个子View的头的位置范围。至于,怎么调用打开,合并的方法很清晰。在方法中isDragViewUnder的范围很小,在调用expandPanel(float offset)方法打开程度,上面会出现一部分的背景效果,然而,给人的第一操作印象便是点击这一块的背景效果区。至于,合拢的情况下,是没有背景效果区的,完全打开的时候也没有背景效果区,只是在打开成都在(0,1)区间会出现,要想在背景区+第二个子View的头区域中的范围点击效果有效,需要在此方法中再进行一次判断,方法如下:
private boolean isDragViewUnder(int x, int y) {
View dragView = mDragView != null ? mDragView : mSlideableView;
if (dragView == null)
return false;
int[] viewLocation = new int[2];
dragView.getLocationOnScreen(viewLocation);
int[] parentLocation = new int[2];
this.getLocationOnScreen(parentLocation);
int screenX = parentLocation[0] + x;// 0
int screenY = parentLocation[1] + y;// 113
//背景区域+第二个子View的点击。。。
if (isAnchored() && screenX >= viewLocation[0]
&& screenX < viewLocation[0] + dragView.getWidth()
&& y < viewLocation[1] + dragView.getHeight()) {
collapsePane();
return false;
} else {
return screenX >= viewLocation[0]
&& screenX < viewLocation[0] + dragView.getWidth()
&& screenY >= viewLocation[1]
&& screenY < viewLocation[1] + dragView.getHeight();
}
}
可能 y < viewLocation[1] + dragView.getHeight()这个条件不是很完美,但是,功能还是实现了。望赐,更好的处理方式。谢谢!
- SlidingUpPanel的使用
- SlidingupPanel
- SlidingUpPanel
- android SlidingUpPanel (一)
- android SlidingUpPanel(二)
- 自定义ViewGroup+ViewDragHelper 自己做个SlidingUpPanel
- GUID使用的使用
- ${}的使用
- 的使用
- @[],@()的使用
- ->的使用
- +、-、*、/、%的使用
- &&的使用
- %:的使用
- Makefile中使用$$的使用
- Makefile中使用$$的使用
- Red5的使用--使用日志
- prefernce的使用具体使用
- android 学习之路(surfaceView) --- 游戏手柄设计
- 【KMP】 HDOJ 3746 Cyclic Nacklace
- HDU 1130 How Many Trees? 卡特兰数
- 挂载 命令 mount /dev/sda2 /vita 出现的问题
- HDU 1212 Big Number 大数求余数
- SlidingUpPanel的使用
- 51单片机学习笔记(五)_VSPD+Proteus+串口调试工具+Keil C51实现单片机串口通信仿真
- HDU 1063 Exponentiation 浮点数的幂次方
- 无聊 学下java
- HDU 1018 Big Number N!的位数
- 【JavaScript 封装库】BETA 3.0 测试版发布!
- 第十八周工作总结
- Minimum Window Substring
- 网页向女友/老婆告白和纪念日专用特效