倒计时效果demo

在主activity上三秒倒计时,同时使主activity半透明不可用。我们启动一个dialog类型的activity。
倒计时使用imageview动画,逐渐放大。 在一张图片动画结束后,放下一张图片动画。最后进入其他界面。
1、 启动 dialog类型的activity
Intent intent = new Intent();
intent.setClass(MainActivity.this, DialogReady.class);
startActivity(intent);
2、 DialogReady.java
public class DialogReady extends Activity {
private ImageView mImageViewReady = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_ready);

this.setFinishOnTouchOutside(false);
this.getWindow().getDecorView().setBackgroundColor(android.R.color.transparent);
mImageViewReady = (ImageView)findViewById(R.id.n_ready);
showReadyPicture3();
}

private void showReadyPicture3(){
final ScaleAnimation animation =new ScaleAnimation(0.0f, 1.4f, 0.0f, 1.4f, 
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
animation.setDuration(1000);
mImageViewReady.setImageDrawable(getResources().getDrawable(R.drawable.n3));
mImageViewReady.setAnimation(animation); 
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
showReadyPicture2();
}
});
}
private void showReadyPicture2(){
final ScaleAnimation animation =new ScaleAnimation(0.0f, 1.4f, 0.0f, 1.4f, 
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
animation.setDuration(1000);
mImageViewReady.setImageDrawable(getResources().getDrawable(R.drawable.n2));
mImageViewReady.setAnimation(animation); 
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
showReadyPicture1();
}
});
}
private void showReadyPicture1(){
final ScaleAnimation animation =new ScaleAnimation(0.0f, 1.4f, 0.0f, 1.4f, 
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
animation.setDuration(1000);
mImageViewReady.setImageDrawable(getResources().getDrawable(R.drawable.n1));
mImageViewReady.setAnimation(animation); 

animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Intent intent = new Intent();
intent.setClass(DialogReady.this, L2048Activity.class);
startActivity(intent);
DialogReady.this.finish();
}
});

}
@Override    
//屏蔽back键
public boolean onKeyDown(int keyCode, KeyEvent event) {  
if(keyCode == KeyEvent.KEYCODE_BACK){      
return  true;
}  
return  super.onKeyDown(keyCode, event);     

}
3、activity_ready.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent"
   >
<ImageView 
        android:id="@+id/n_ready"
        android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:src="@drawable/n1"
     android:visibility="visible"
     android:scaleType="fitXY" 
     android:background="@android:color/transparent"
     />
    
    
    </RelativeLayout>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值