이미지가 희미 해지고 사라지는 스플래시 화면 애니메이션을 표시하고 싶습니다. 이미지가 희미 해지면 두 번째 활동을로드하고 싶습니다.스플래시 화면 안드로이드의 알파 애니메이션
- 페이드 타임 (1000 MS)
- 기다림 (1000 MS)
- 페이드 아웃 시간 (1000 MS)
- 기다림 (1000 MS)
- 로드 초 활동
어떻게해야합니까? 현재 사용중인 코드는 다음과 같습니다.
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;
public class Splash extends Activity
{
ImageView img;
Thread timer;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
img = (ImageView) findViewById (R.id.imgSplash);
img.startAnimation(FadeIn(1000));
try
{
Thread.sleep(1000);
}
catch (InterruptedException e1)
{
e1.printStackTrace();
}
img.startAnimation(FadeOut(1000));
try
{
Thread.sleep(1000);
}
catch (InterruptedException e1)
{
e1.printStackTrace();
}
timer.start();
Intent intent = new Intent();
intent.setClass(Splash.this,MainScreen.class);
startActivity(intent);
}
public void onPause()
{
super.onPause();
finish();
}
private Animation FadeIn(int t)
{
Animation fade;
fade = new AlphaAnimation(0.0f,1.0f);
fade.setDuration(t);
fade.setInterpolator(new AccelerateInterpolator());
return fade;
}
private Animation FadeOut(int t)
{
Animation fade;
fade = new AlphaAnimation(1.0f,0.0f);
fade.setDuration(t);
fade.setInterpolator(new AccelerateInterpolator());
return fade;
}
}
도와주세요.
두 번째 활동이 시작되지 않습니까? 아니면 시작될 것이라고 확인 하시겠습니까? – Addison
1) 타이머가 초기화되지 않습니다. – fiddler
사용자가 응용 프로그램을 사용할 때마다 4 초 동안 불필요하게 기다리지 않도록하십시오. 이렇게함으로써 당신은 그들의 시간을 낭비하고 있습니다 (그것은 그들을 귀찮게 할 것입니다). 활동을 시작하기 전에로드해야 할 것이 있다면 적재 중에 스플래시를 보여주십시오. 응용 프로그램에 도착하기 전에 임의의 지연 시간을 추가하여 시간을 낭비하는 것입니다. [이 기사를보십시오] (http://blog.iangclifton.com/2011/01/01/android-splash-screens-done-right/). 어떻게 제대로하는지 알려줄 것입니다. – FoamyGuy