mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-29 06:44:08 +00:00
Android: fix content positioning
The getWindowVisibleDisplayFrame seems to return a rectangle in the screen coordinate and cut the room for the camera. The problem is that the Window is somehow already displaced. The insets seems to be a better way to get that value. Fixes #5242
This commit is contained in:
parent
b3181b05a2
commit
dea51f2055
1 changed files with 11 additions and 0 deletions
|
@ -6,6 +6,7 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import android.content.ClipData;
|
||||
|
@ -466,6 +467,16 @@ public class SlintAndroidJavaHelper {
|
|||
public Rect get_view_rect() {
|
||||
Rect rect = new Rect();
|
||||
mActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
|
||||
WindowInsets insets = mActivity.getWindow().getDecorView().getRootView().getRootWindowInsets();
|
||||
if (insets != null) {
|
||||
int dx = rect.left - insets.getSystemWindowInsetLeft();
|
||||
int dy = rect.top - insets.getSystemWindowInsetTop();
|
||||
|
||||
rect.left -= dx;
|
||||
rect.right -= dx;
|
||||
rect.top -= dy;
|
||||
rect.bottom -= dy;
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue