gpt4 book ai didi

android - AnimationDrawable 持续时间属性

转载 作者:行者123 更新时间:2023-11-29 14:05:34 25 4
gpt4 key购买 nike

我的 xml 文件中的 android:duration 属性有问题。那是我的代码:

<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item
android:drawable="@drawable/eye_1"
android:duration="150" />
<item
.
.
.
</animation-list>

有 8 张图片。这是我的 Activity 代码:

    public class MyActivity extends Activity {
AnimationDrawable frameAnimation;
private MediaPlayer mp;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sauron);
mp = MediaPlayer.create(this, R.raw.sound);
mp.setLooping(true);
mp.start();

ImageView imgView = (ImageView) findViewById(R.id.animationImage);
// imgView.setVisibility(ImageView.VISIBLE);
imgView.setBackgroundResource(R.drawable.animation);

frameAnimation = (AnimationDrawable) imgView
.getBackground();


// Get instance of Vibrator from current Context
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(10000);
}
@Override public void onWindowFocusChanged(boolean hasFocus) {
frameAnimation.start();
super.onWindowFocusChanged(hasFocus); }

@Override
protected void onStop()
{
// Stop play
super.onStop();
mp.stop();
}
}

一切正常,但图像之间的持续时间存在问题。无论我在 android:duration 属性中输入多少数字,动画都运行得非常快。有谁知道哪里出了问题?

谢谢

最佳答案

持续时间以“毫秒”为单位,这意味着 150 非常非常快当 1500 是 1.5 秒时,150 表示 0.15 秒,刚好超过十分之一秒

尝试输入一个以千为单位的数字,例如 1500 或 3000,看看是否可行

关于android - AnimationDrawable 持续时间属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7261407/

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