Comments (1)
@summersky14 增加范围判断即可
在IFloatWindowImpl中增加判断
/**
* 判断是否超出范围,根据自己需求设置比例大小,我自己设置的是0.025和0.975
* @param x event.getRawX()
* @param y event.getRawY()
* @return
*/
private boolean isOutOfRange(float x, float y) {
boolean b = true;
float screenWidth = Util.getScreenWidth(mB.mApplicationContext);
float screenHeight = Util.getScreenHeight(mB.mApplicationContext);
float widthRate, heightRate;
widthRate = (screenWidth - x) / screenWidth;
heightRate = (screenHeight - y) / screenHeight;
if (widthRate > 0.025 && widthRate < 0.975 && heightRate > 0.025 && heightRate < 0.975) {
b = false;
} else {
b = true;
}
return b;
}
然后在case MotionEvent.ACTION_MOVE 中判断即可
case MotionEvent.ACTION_MOVE:
if (!isOutOfRange(event.getRawX(), event.getRawY())) {
changeX = event.getRawX() - lastX;
changeY = event.getRawY() - lastY;
newX = (int) (mFloatView.getX() + changeX);
newY = (int) (mFloatView.getY() + changeY);
mFloatView.updateXY(newX, newY);
if (mB.mViewStateListener != null) {
mB.mViewStateListener.onPositionUpdate(newX, newY);
}
lastX = event.getRawX();
lastY = event.getRawY();
}
break;
from floatwindow.
Related Issues (20)
- 横屏靠右,切换横竖靠右 有问题 HOT 1
- androidP 9.0 悬浮权限无法申请
- 可以不申请权限使用吗
- 可以不申请权限吗 HOT 2
- 自定义布局存在把悬浮窗拖到边缘位置,里面有控件的情况下拖不动,因为里面的组件把事件拿走了
- FloatWindow of this tag has been added
- 被拖出去了,怎么办呀
- 设置自定义布局动画啊无效
- 当前Activity不在显示列表中,点击Home后如何显示?
- 悬浮窗中的edittext无法弹出输入法 HOT 1
- 应用打开权限页面时用户直接返回应用,再次调用代码块时出错
- setDesktopShow(false),返回后,闪一下就消失了 HOT 1
- 根布局view
- 点击事件怎么设置呢 HOT 4
- 进入APP不显示 ,然后我点击就显示,后台通知显示
- 不需要权限的悬浮窗方案了解一下~
- hasPermissionForO在8.0实际无效
- 我发现我的点击事件也不能设置emm
- 作者貌似弃坑了,推荐另外一款悬浮窗框架 HOT 1
- 重启app后不显示的问题,设置左面显示未true,不想要桌面显示的效果可以在ondestory销毁就可以了
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from floatwindow.