Java 需要制作逐帧启动屏幕的教程或帮助吗?
我一直在寻找这方面的问题和答案,但没有找到任何有帮助的。我有13个png。我试图在闪屏中一个接一个地运行的图像。这是我正在使用的代码 splash.xmlJava 需要制作逐帧启动屏幕的教程或帮助吗?,java,android,xml,splash-screen,Java,Android,Xml,Splash Screen,我一直在寻找这方面的问题和答案,但没有找到任何有帮助的。我有13个png。我试图在闪屏中一个接一个地运行的图像。这是我正在使用的代码 splash.xml <ImageView android:contentDescription="@string/desc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/logo" android:background="
<ImageView
android:contentDescription="@string/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/logo"
android:background="@drawable/logo" />
}
我有13个png。我试图在闪屏中一个接一个地运行的图像
创建一个。在XML中列出每个PNG以及在该框架上花费的时间。在您的
ImageView
中使用该AnimationDrawable
,并在其上调用startAnimation()
,使其开始动画制作。请帮您的用户一个忙,不要在您的应用程序中设置初始屏幕。这段代码目前做什么?您希望它做什么?你能缩小你的问题具体是什么吗?嗨,哈弗,目前代码(启动屏幕)打开一个png背景和声音文件。但是,我希望它能够打开大约12个png文件(一个接一个),让它看起来像一个动画快照。这似乎很简单,但我无法让它工作。有什么帮助吗?@user2100950:如果单击答案中的超链接,您将看到AnimationDrawable
的文档,其中显示了用图像定义超链接的XML语法,并向您展示了如何应用超链接。请注意,您需要将其应用于图像视图的背景(这是有原因的,尽管我现在忘记了它是什么…)。这里有关于AnimationDrawable
的附加文档:好的,我把这段代码放在splash.java super.onCreate(savedInstanceState)中;ImageView img=(ImageView)findViewById(R.id.spining\u wheel\u image);img.setBackgroundResource(R.drawable.spin_动画);AnimationDrawable frameAnimation=(AnimationDrawable)img.getBackground();frameAnimation.start();但我有3个错误,都是说旋转动画无法解决或不是一个问题field@user2100950:是否创建了名为res/drawable/spin_animation.XML的XML文件?好的,我刚导入了AnimationDrawable,但仍有2个错误,表示无法解析或不是字段spin_动画。请帮忙??很抱歉
public class Splash extends Activity{
Animation animation;
MediaPlayer ourSong;
@Override
public void onAttachedToWindow() {
// TODO Auto-generated method stub
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
ourSong = MediaPlayer.create(Splash.this, R.raw.splashsound);
ourSong.start();
Thread timer = new Thread(){
public void run(){
try{
sleep(7000);
} catch (InterruptedException e){
e.printStackTrace();
}finally{
Intent openStartingPoint = new Intent("com.thegoodwarren.lonte.STARTINGPOINT");
startActivity(openStartingPoint);
}
}
};
timer.start();
StartAnimations();
}
private void StartAnimations() {
// TODO Auto-generated method stub
Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
anim.reset();
LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay);
l.clearAnimation();
l.startAnimation(anim);
anim = AnimationUtils.loadAnimation(this, R.anim.translate);
anim.reset();
ImageView iv = (ImageView) findViewById(R.id.logo);
iv.clearAnimation();
iv.startAnimation(anim);
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
ourSong.release();
finish();
}