protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
a=(ImageView)findViewById(R.id.imageView1);
b=(ImageView)findViewById(R.id.imageView2);
c=(ImageView)findViewById(R.id.imageView3);
d=(ImageView)findViewById(R.id.imageView4);
e=(ImageView)findViewById(R.id.imageView5);
aAnimation(savedInstanceState);
bAnimation(savedInstanceState);
cAnimation(savedInstanceState);
dAnimation(savedInstanceState);
eAnimation(savedInstanceState);
}
private void aAnimation(Bundle savedInstanceState) {
Animation aa=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slideup);
a.startAnimation(aa);
}
private void bAnimation(Bundle savedInstanceState) {
Animation aa=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slideup);
b.startAnimation(aa);
}
private void cAnimation(Bundle savedInstanceState) {
Animation aa=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slideup);
c.startAnimation(aa);
}
private void dAnimation(Bundle savedInstanceState) {
Animation aa=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slideup);
d.startAnimation(aa);
}
private void eAnimation(Bundle savedInstanceState) {
Animation aa=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slideup);
e.startAnimation(aa);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.welcome, menu);
return true;
}
答案 0 :(得分:2)
您可以使用 startOffset
http://developer.android.com/reference/android/view/animation/Animation.html
动画运行前的延迟时间,一旦开始时间为 达到。
例如:
在XML中:
<set android:startOffset="1000">
<scale
android:fromXScale="0.5"
android:toXScale="1.0"
android:fromYScale="0.5"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000" />
</set>
OR
在JAVA中:
Animation aa = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.slideup);
aa.setStartOffset(1000);
a.startAnimation(aa);
答案 1 :(得分:1)
您可以使用Handler
s延迟
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
// run animation
}
}, 1000); //1 sec