Skip to content

[Bug]: Window position jumps when window content size changes on Android 13-14 #83

Description

@ElliotAl86

Framework Version [Required]

Source code of v12.0

Issue Description [Required]

Hello!
I encountered window position jumps when changing the content size.
This only applies to the global floating window.
I can reproduce this bug on my physical device with API level 33 and in the Android Studio emulator with API 33 and 34. It’s not reproducible on API levels 32 or 35-36 in the emulator.

Steps to Reproduce [Required]

For tests I used sources of v12.0 and changed EasyWindow initialization in method showGlobalWindow() like this:

EasyWindow.with(application)
        .setContentView(R.layout.expanding_layout)
        .setGravity(Gravity.END | Gravity.BOTTOM)
        .setYOffset(200)
        // 设置指定的拖拽规则
        .setWindowDraggableRule(springBackWindowDraggableRule)
        .setOnClickListenerByView(R.id.root_container, new OnWindowViewClickListener<LinearLayout>() {

            @Override
            public void onClick(@NonNull EasyWindow<?> easyWindow, @NonNull LinearLayout view) {
                ImageView firstView = view.findViewById(R.id.first_part);
                if (firstView.getVisibility() == View.VISIBLE) {
                    firstView.setVisibility(View.GONE);
                } else {
                    firstView.setVisibility(View.VISIBLE);
                }
            }
        })
        .setOnWindowLifecycleCallback(new OnWindowLifecycleCallback() {

            @Override
            public void onWindowCancel(@NonNull EasyWindow<?> easyWindow) {
                // 在窗口消失的时候回收资源,避免 LeakCanary 一直报内存泄漏,关于这点框架文档有介绍,详情请看文档
                easyWindow.recycle();
            }
        })
        .show();

Also added 1 layout file (expanding_layout.xml):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root_container"
    android:orientation="horizontal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/first_part"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:visibility="gone"
        android:src="#FFAA00" />

    <ImageView
        android:id="@+id/second_part"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="#FFAA00AA" />

</LinearLayout>

Steps to reproduce:

  1. Modify sources as above
  2. Show global floating window
  3. Move window to new position and click to change window size (repeat if needed)

Is the Issue Reproducible? [Required]

Yes

Project targetSdkVersion [Required]

33

Device Information [Required]

Asus ZB602KL and last Android Studio emulator

Android Version [Required]

13 and 14

Issue Source Channel [Required]

Encountered by myself

Is it specific to certain device models? [Required]

No

Does the latest version of the framework have this issue? [Required]

Yes

Is the issue mentioned in the framework documentation? [Required]

No

Did you consult the framework documentation but couldn't find a solution? [Required]

Yes

Has a similar issue been reported in the issue list? [Required]

No

Have you searched the issue list but couldn't find a solution? [Required]

Yes

Can the issue be reproduced with a demo project? [Required]

Yes

Provide Error Stack Trace


Provide Screenshots or Videos

test.mp4

Provide a Solution

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions