虽然您没有具体说明您想要的动画类型,但我只会将此答案限制为 Android Animation 类中的选项。
android中的Animation(http://developer.android.com/reference/android/view/animation/Animation.html)类基本分为AlphaAnimation、RotateAnimation、ScaleAnimation、TranslateAnimation四种。每个都操作一种特定类型的对象属性。
AplahAmiation:控制对象 Alpha 级别的动画。用于淡入淡出。
RotateAnimation:控制物体旋转的动画
ScaleAnimation:控制对象比例的动画。您可以指定用于缩放中心的点。
TranslateAnimation:控制对象位置的动画
你也可以使用 AnimationsSet 来表示一组应该一起播放的动画。
我将使用其中一个属性作为示例,然后您可以从那里获取它。
AlphaAnimation alpha;
TextView splashText, splashText2;
Handler handler;
Runnable runnable = new Runnable() {
@Override
public void run() {
splashText2.setVisibility(1);
splashText2.setText(splashText2.getText().toString() + ".");
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash_screen);
alpha= new AlphaAnimation(0, 1);
alpha.setDuration(1000);
handler = new Handler();
splashText = (TextView)findViewById(R.id.slash_test);
Thread myTread = new Thread(){
public void run() {
try {
sleep(1500);
handler.post(runnable);
sleep(500);
handler.post(runnable);
sleep(500);
handler.post(runnable);
sleep(500);
handler.post(runnable);
Intent changeActivity = new Intent(SplashScreen.this, WelcomeScreen.class);
startActivity(changeActivity);
} catch (InterruptedException e) {
e.printStackTrace();
}
finally{
finish();
}
};
};
myTread.start();
splashText.setAnimation(alpha);
}
这将创建一个 splascreen,使文本淡入并连续动画加载...
线
splashText2.setVisibility(1);
会将可见度从 0 更改为 1