【问题标题】:How to display animation on splash screen with different images in android如何在android中使用不同图像在启动画面上显示动画
【发布时间】:2012-09-10 12:16:07
【问题描述】:

我有几个徽标的图像,我想将它显示在我的初始屏幕上并制作一个完整的徽标,就像拼图一样。我该怎么做。

我是第一次用,谁能帮帮我。

谢谢

【问题讨论】:

标签: android animation splash-screen


【解决方案1】:
package com.techipost.imageslider;

import android.app.Activity;
import android.os.Bundle;
import android.view.*;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.os.Handler;
import java.util.Timer;
import java.util.TimerTask;
import com.techipost.imageslider.R;

public class SliderActivity extends Activity {

    public int currentimageindex=0;
    Timer timer;
    TimerTask task;
    ImageView slidingimage;

    private int[] IMAGE_IDS = {
            R.drawable.splash0, R.drawable.splash1, R.drawable.splash2,
            R.drawable.splash3
        };

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mygame);
        final Handler mHandler = new Handler();

        // Create runnable for posting
        final Runnable mUpdateResults = new Runnable() {
            public void run() {

                AnimateandSlideShow();

            }
        };

        int delay = 1000; // delay for 1 sec.

        int period = 8000; // repeat every 4 sec.

        Timer timer = new Timer();

        timer.scheduleAtFixedRate(new TimerTask() {

        public void run() {

             mHandler.post(mUpdateResults);

        }

        }, delay, period);



    }

    public void onClick(View v) {

        finish();
        android.os.Process.killProcess(android.os.Process.myPid());
      }

    /**
     * Helper method to start the animation on the splash screen
     */
    private void AnimateandSlideShow() {        

        slidingimage = (ImageView)findViewById(R.id.ImageView3_Left);
        slidingimage.setImageResource(IMAGE_IDS[currentimageindex%IMAGE_IDS.length]);

        currentimageindex++;

        Animation rotateimage = AnimationUtils.loadAnimation(this, R.anim.custom_anim);   

         // slidingimage.startAnimation(rotateimage);            

    }    


}

【讨论】:

  • 实际上我已经将我的图像放在一个数组中,它有 60 个徽标图像,我想以 1 秒的间隔一张一张地显示它
  • 再见一张图像在图像视图中完成徽标..这可能吗请帮助我我已经尝试了很多,但没有得到正确的解决方案
  • 不,我不能……我没有聊天积分。至少需要 20 积分才能聊天。
  • manisivapuram.blogspot.in/2011/06/… hey trisha 如果有用,请参考此链接
【解决方案2】:

试试这个方法,保持 AnimateandSlideShow() 函数不变

   new CountDownTimer(1000,60000) {
                // 1000(1 sec interval time)
               // 250 (0.25 sec) 
        @Override
        public void onTick(long millisUntilFinished) {
            // TODO Auto-generated method stub

            AnimateandSlideShow();

        }

        @Override
        public void onFinish() {
            // TODO Auto-generated method stub

            // Call NextActivity

            Intent intent = new Intent(this,NewActivityName.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        }
    }.start();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多