gpt4 book ai didi

android - fragment 在移除时闪烁

转载 作者:行者123 更新时间:2023-11-30 01:10:24 26 4
gpt4 key购买 nike

如果我在将 fragment 的 View 设置为可见性 View.GONE/View.INVISIBLE 后移除 fragment , fragment 的移除会导致 View 在移除之前再次闪烁。我怎样才能避免这种情况

fragment.getView().setVisibility(View.INVISIBLE);

之后:

ft.remove(fragment);
ft.commitAllowingStateLoss();

我没有使用隐藏,因为我自己做动画,在 onAnimationEnd 时我确实提交了删除。

然后Fragment的View闪烁然后被移除。

最佳答案

我通过将高度设置为 0 和 INVISIBLE 而不是 View.GONE 来做到这一点:

fragment.getView().setVisibility(View.INVISIBLE);
ViewGroup.LayoutParams params = fragment.getView().getLayoutParams();
params.height = 0;
fragment.getView().setLayoutParams(params);

关于android - fragment 在移除时闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38461654/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com