Skip to content

requestLayout()导致仿微信的联动动画失效 #61

Description

@myt386289635

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { final ScrollView scrollView = (ScrollView) findViewById(R.id.sv_data); final View decorView = getWindow().getDecorView(); decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { Rect rect = new Rect(); decorView.getWindowVisibleDisplayFrame(rect); int screenHeight = decorView.getRootView().getHeight(); int heightDifference = screenHeight - rect.bottom;//计算软键盘占有的高度 = 屏幕高度 - 视图可见高度 LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) scrollView.getLayoutParams(); layoutParams.setMargins(0, 0, 0, heightDifference);//设置ScrollView的marginBottom的值为软键盘占有的高度即可 scrollView.requestLayout(); } }); }

这是解决透明状态栏导致软件盘弹出后,ScrollView滑动失效的问题。
加了这段代码以后,我发现放微信效果的联动动画失效了。其他页都是正常的,就打开这种页面动画就消失了。经过一番测试,我发现是scrollView.requestLayout();这句话导致动画消失的,想请教一下作者,这个问题怎么解决?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions