- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 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/
我如何从代码而不是从 xml 将图像加载到动画,我有这个例子: java文件: ImageView img = (ImageView)findViewById(R.id.spinn
我现在正在编写一个应用程序,它使用占据大部分屏幕的四个主要按钮。每个都有三个动画:一个 12 帧的介绍动画、一个 33 帧的循环动画和一个基于当前帧关闭循环的动画。 图像高度在 250 250 到 4
我有一个 AnimationDrawable,我在开始动画之前初始化它并在它结束时回收它。问题是当我想再次开始动画时,我重新初始化所有内容但仍然给出异常 java.lang.RuntimeExcept
我想为四张图片设置动画以连续显示。在布局 XML 文件中,我正在创建一个 ImageView: 然后在我的代码中创建 AnimationDrawablevia private void startA
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我的 xml 文件中的 android:duration 属性有问题。那是我的代码: 有 8 张图片。这是我的 Activity 代码: public class MyActivity
我有同样的问题question asked 2 years ago没有有效答案(请不要为重复的内容关闭此问题;目前还没有答案/解决方案)。 所以,我有一个以编程方式制作的 AnimationDrawa
在可绘制动画中,您可以加载一个包含多个帧的动画列表,这些帧会一个接一个地播放。我只是想知道这里的内存消耗/效率。如果我有 50 或 60 张图片,这是否意味着它们全部加载到内存中然后一张一张地渲染,或
我有一个最初有位图图像的 ImageView: 默认情况下,imageview 会缩放位图以填充我想要的宽度。 但问题是,当我将 ImageView 的源更改为 AnimationDrawa
我以编程方式创建的 AnimationDrawable 有问题,当我通过 imageView.setBackgroundDrawable 将它分配给 ImageView 时,它就会启动(我支持 API
我正在关注 Google 提供的如何将 AnimationDrawable 与 ImageView 结合使用的示例。您可以在这里找到它:http://developer.android.com/gui
我有一组 10 张图像,我想创建一个动画,在这些图像之间交叉淡入淡出。我一直在研究内置的 Drawable 来实现这样的事情,但那部分运气不好。有 AnimationDrawable,它可以在图片之间
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 9 年前。 Improve t
我的代码: package net.tq5.bubbleexplosion; import android.app.Activity; import android.content.Context;
所以我希望我的动画在 Activity 创建后立即开始,但出于某种原因,无论我尝试什么都会让它开始。我可以通过点击事件来启动它,但我希望它自己启动。 这是我所拥有的,我该如何让它发挥作用? packa
我想用几个图像文件制作动画,为此 AnimationDrawable 效果很好。但是,我需要知道动画何时开始以及何时结束(即添加一个像 Animation.AnimationListener 这样的监
我必须为一个循环倒数计时器设置动画,我通过使用 AnimationDrawable 为 ImageView 的背景设置动画来实现(每个图像都删除了相应的圆切片)。问题是用户可以暂停这个动画,所以我必须
我正在尝试使用 AnimationDrawable 为一组图像制作动画。用户应该能够通过单击按钮暂停/恢复动画。我正在这样做,使用 setVisible(boolean visible, boolea
我正在开发一个应用程序,一旦我摇动手机,它就会执行某项功能。为此,我创建了一个名为 ShakeListener 的类。当我打开它时,我的应用程序运行得非常好。当我打开应用程序并按后退按钮并转到主屏幕并
我正在尝试让我的 Android 应用程序上的 AnimationDrawable 重复。我将 android:oneshot 配置为 false。 (尝试使用 java 和 XML)尽管如此,无论何
我是一名优秀的程序员,十分优秀!