SplashScreen - 关闭的时间

时间:2015-11-28 05:21:20

标签: android android-intent timer splash-screen

我在我的应用程序中使用Internet代码部署了一个启动画面,一切正常但无法为此活动设置关闭时间并打开主应用程序可以帮助我。我已经尝试过处理程序的形状,但是在一段时间后关闭了应用程序。

package com.packpage.application;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;

import com.packpage.application.FontelloTextView;
import com.packpage.application.KenBurnsView;

public class SplashScreensActivity extends Activity {

    public static final String SPLASH_SCREEN_OPTION = "com.packpage.application.SplashScreensActivity";
    public static final String SPLASH_SCREEN_OPTION_1 = "Option 1";
    public static final String SPLASH_SCREEN_OPTION_2 = "Option 2";
    public static final String SPLASH_SCREEN_OPTION_3 = "Option 3";

    private KenBurnsView mKenBurns;
    private FontelloTextView mLogo;
    private TextView welcomeText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().requestFeature(Window.FEATURE_NO_TITLE); //Removing ActionBar
        setContentView(R.layout.activity_splash_screen);

        mKenBurns = (KenBurnsView) findViewById(R.id.ken_burns_images);
        mLogo = (FontelloTextView) findViewById(R.id.logo);
        welcomeText = (TextView) findViewById(R.id.welcome_text);
        mKenBurns.setImageResource(R.drawable.splash_screen_background);

        String category = SPLASH_SCREEN_OPTION_1;
        Bundle extras = getIntent().getExtras();
        if (extras != null && extras.containsKey(SPLASH_SCREEN_OPTION)) {
            category = extras.getString(SPLASH_SCREEN_OPTION, SPLASH_SCREEN_OPTION_1);
        }
        setAnimation(category);
    }

    /** Animation depends on category.
     * */
    private void setAnimation(String category) {
        if (category.equals(SPLASH_SCREEN_OPTION_1)) {
            animation1();
        } else if (category.equals(SPLASH_SCREEN_OPTION_2)) {
            animation2();
        } else if (category.equals(SPLASH_SCREEN_OPTION_3)) {
            animation2();
            animation3();
        }
    }

    private void animation1() {
        ObjectAnimator scaleXAnimation = ObjectAnimator.ofFloat(mLogo, "scaleX", 5.0F, 1.0F);
        scaleXAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
        scaleXAnimation.setDuration(1200);
        ObjectAnimator scaleYAnimation = ObjectAnimator.ofFloat(mLogo, "scaleY", 5.0F, 1.0F);
        scaleYAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
        scaleYAnimation.setDuration(1200);
        ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(mLogo, "alpha", 0.0F, 1.0F);
        alphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
        alphaAnimation.setDuration(1200);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.play(scaleXAnimation).with(scaleYAnimation).with(alphaAnimation);
        animatorSet.setStartDelay(500);
        animatorSet.start();
    }

    private void animation2() {
        mLogo.setAlpha(1.0F);
        Animation anim = AnimationUtils.loadAnimation(this, R.anim.translate_top_to_center);
        mLogo.startAnimation(anim);
    }

    private void animation3() {
        ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(welcomeText, "alpha", 0.0F, 1.0F);
        alphaAnimation.setStartDelay(1700);
        alphaAnimation.setDuration(500);
        alphaAnimation.start();
    }
}

1 个答案:

答案 0 :(得分:1)

看一下本教程 http://www.androidhive.info/2013/07/how-to-implement-android-splash-screen-2/

使用处理程序

<li class="col-md-3 col-sm-6 col-xs-12 isotope-item websites">
    <div class="image-gallery-item">
        <span class="thumb-info" id='thump-info'>

        <div class="my-gallery" itemscope itemtype="">
            <?php 
            $i = 0;
            $sql=mysql_query("SELECT * FROM useralbum WHERE ssmid='$ssmid' ORDER BY photo_uploadedon DESC");
            $count = mysql_num_rows($sql);
            while($row=mysql_fetch_assoc($sql)){
            ?>
            <figure <?php if(0 != $i) { ?>style="display:none;" <?php } ?>>
              <a href="http://www.srisankaramatrimony.com/cupid/img/user-album/thumbnail/<?php echo $row['thumbnail']?>" itemprop="contentUrl" data-size="1600x1600">
                  <img src="http://www.srisankaramatrimony.com/cupid/img/user-album/thumbnail/<?php echo $row['thumbnail']?>" itemprop="thumbnail" alt="Image description" style='dispaly:none'/>
              </a>
            </figure>
            <?php $i++; } ?>
        </div>
        <span class="thumb-info-title">
            <span class="thumb-info-inner">VIEW PHOTOS</span>
            <span class="thumb-info-type"><?php echo $count.'  PHOTOS'?></span>
        </span>
        <span class="thumb-info-action">
            <span class="thumb-info-action-icon"><i class="fa fa-link"></i></span>
        </span>

        </span>
    </div>
    </li>
[THis one for 800×1280 ,see the forth image width is not comming corectly]


 http://i.stack.imgur.com/ouSop.png

SPLASH_TIME_OUT是以毫秒为单位的时间。在run方法

中开始下一个活动