Comments (3)
I have same question too.
More, I found when I set 'alignment: OverlayAlignment.center' and 'positionGravity: PositionGravity.auto', the overlay will sticking on center or out-of-screen.
Could this situation been solved by anyway?
from flutter_overlay_window.
Hi X-SLAYER, recently I've been trying to solve these issues. Currently, I've made some adjustments that seem to work, but my experience in coding isn't extensive. Even though I've done my best, these might just be temporary solutions. Hope they can be of some help, I also want to hear feedback on this work:
public TrayAnimationTimerTask() {
super();
int left = 0;
int right = szWindow.x - flutterView.getWidth();
int top = 0 + mStatusBarHeight;
int bottom = szWindow.y - mNavigationBarHeight - flutterView.getHeight() / 4;
int regulateOffsetX = (szWindow.x - flutterView.getWidth()) / 2;
int regulateOffsetY = szWindow.y / 2;
// Solve the offset issue with including Gravity.CENTER setting
if (WindowSetup.gravity == (Gravity.TOP)
|| WindowSetup.gravity == (Gravity.CENTER)
|| WindowSetup.gravity == (Gravity.BOTTOM)) {
left = left - regulateOffsetX;
right = right - regulateOffsetX;
}
if (WindowSetup.gravity == (Gravity.LEFT | Gravity.CENTER)
|| WindowSetup.gravity == (Gravity.CENTER)
|| WindowSetup.gravity == (Gravity.RIGHT | Gravity.CENTER)) {
top = top - regulateOffsetY;
bottom = bottom - regulateOffsetY;
}
// Solve the slight offset issue with including Gravity.BOTTOM setting
if ((WindowSetup.gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
top = top - flutterView.getHeight() / 2;
bottom = bottom - flutterView.getHeight() / 2;
}
switch (WindowSetup.positionGravity) {
case "auto":
mDestX = (params.x + (flutterView.getWidth() / 2)) <= right / 2 ? left : right;
break;
case "left":
mDestX = left;
break;
case "right":
mDestX = right;
break;
default:
mDestX = params.x;
mDestY = params.y;
break;
}
mDestY = lastYPosition;
// Solve the problem of floating window being able to move out of the viewport
mDestX = Math.max(left, Math.min(mDestX, right));
mDestY = Math.max(top, Math.min(mDestY, bottom));
return;
}
Note: Some algorithms are adjusted based on my personal preference for visual effects. Feel free to modify them as you see fit.
from flutter_overlay_window.
Additionally, I'd like to ask about the principle behind params.y = -statusBarHeightPx() in onStartCommand(). Is it more accurate to use a positive number, or am I overlooking some considerations?
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowSetup.width == -1999 ? -1 : WindowSetup.width,
WindowSetup.height != -1999 ? WindowSetup.height : screenHeight(),
0,
-statusBarHeightPx(),
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY : WindowManager.LayoutParams.TYPE_PHONE,
WindowSetup.flag | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
| WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
PixelFormat.TRANSLUCENT
);
from flutter_overlay_window.
Related Issues (20)
- Does it use Google Play services? HOT 1
- You can use the resize overlay and pass the enableDrag params HOT 2
- Could not run the example
- FlutterOverlayWindow.showOverlay(height: WindowSize.fullcover) wont work
- Listview scroll event conflicts with FlutterOverlayWindow drag, HOT 1
- Save overlay position
- Open the main app from floating window? HOT 5
- MissingPluginException HOT 1
- Open Overlay from background when app is kill state HOT 3
- Android 14 requirese foregroundServiceType HOT 1
- Crash in production HOT 4
- Does not display all objects
- I can't display my data on the overlay window. HOT 3
- Unable to create service flutter.overlay.window.flutter_overlay_window.OverlayService: HOT 4
- Add support for android API 34 HOT 1
- Height doesn't account for status bar
- Use of `FlutterEngineGroup` instead of simply using `FlutterEngine` HOT 1
- Overlay stops sending messages to UI when it's turned on after previously being closed after app termination
- Unable to create multiple overlay window. HOT 4
- Please add more flags to show when phone is looked HOT 2
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 flutter_overlay_window.