gpt4 book ai didi

android - 在屏幕android上随机 move 按钮

转载 作者:行者123 更新时间:2023-11-29 01:52:07 25 4
gpt4 key购买 nike

我是 android 开发的新手。我想在屏幕上有一个连续 move 的单一按钮。当它接触到侧面时,它应该反弹回来。点击时打开 Activity 。我该怎么做呢?任何有用的链接?想法?谢谢!

最佳答案

move 按钮需要使用动画这是它的 fragment

TranslateAnimation  mAnimation = new TranslateAnimation(
TranslateAnimation.RELATIVE_TO_PARENT, 1f,
TranslateAnimation.RELATIVE_TO_PARENT, -1.2f,
TranslateAnimation.ABSOLUTE, 0f,
TranslateAnimation.ABSOLUTE, 0f
);
mAnimation.setDuration(15000);
mAnimation.setRepeatCount(-1);
mAnimation.setRepeatMode(Animation.INFINITE);
mAnimation.setInterpolator(new LinearInterpolator());
mAnimation.setFillAfter(true);

LinearLayout alertlayout = (LinearLayout) findViewById(R.id.alertll);
alertlayout.startAnimation(mAnimation);

并开启一个新的 Activity

Intent intent = new Intent(YourActivity.this,NewActivity.class);
StartActivity(intent);

关于android - 在屏幕android上随机 move 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17311875/

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