gpt4 book ai didi

android - beginDelayedTransition 不起作用,仅显示最终 View 位置

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:58:21 24 4
gpt4 key购买 nike

我想将按钮移动到中心,显示它,然后移动到角落。

但它不会动,它立即出现在角落里。为什么?

更新 Android 5.1,API 22。

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// remember true position/size
final RelativeLayout.LayoutParams layoutParams_= (RelativeLayout.LayoutParams) mapFollowButton.getLayoutParams();
// create temp position/size from which will move
final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams((int) (150*density), (int) (150*density));
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
mapFollowButton.setLayoutParams(layoutParams);
mapFollowButton.setVisibility(View.INVISIBLE);
mapFollowButton.invalidate();

final ChangeBounds transition= new ChangeBounds();
transition.setDuration(1000L);
TransitionManager.beginDelayedTransition((ViewGroup) findViewById(R.id.mainRL),transition);
//here expected to move to true position from center
mapFollowButton.setLayoutParams(layoutParams_);
mapFollowButton.setVisibility(View.VISIBLE);
} else
mapFollowButton.setVisibility(View.VISIBLE);

最佳答案

好吧,我找到了解决方案。有效,但奇怪的是,没有提到这一点。只需要暂停一下,哪怕是10ms。其余相同。

                ....
//mapFollowButton.invalidate();

mapFollowButton.postDelayed(new Runnable() {
@Override
public void run() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
final ChangeBounds transition= new ChangeBounds();
transition.setDuration(1000L);
TransitionManager.beginDelayedTransition((ViewGroup) findViewById(R.id.mainRL),transition);
}
mapFollowButton.setLayoutParams(layoutParams_);
mapFollowButton.setVisibility(View.VISIBLE);
}
},10);

关于android - beginDelayedTransition 不起作用,仅显示最终 View 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38799024/

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