安卓欢迎页的写法

  • Post author:
  • Post category:其他


layout :

<?xml version=”1.0″ encoding=”utf-8″?>

<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”

android:orientation=”vertical”

android:background=”#fff”

android:layout_width=”fill_parent”

android:layout_height=”fill_parent”

>

<ImageView

android:id=”@+id/imageView_welcome”

android:layout_width=”match_parent”

android:layout_height=”match_parent”

android:src=”@drawable/wellcom” />

</LinearLayout>

java:


public class Wellcom extends Activity implements AnimationListener{




private ImageView  imageView = null;

private Animation alphaAnimation = null;

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.wellcome);

imageView = (ImageView)findViewById(R.id.imageView_welcome);

alphaAnimation = AnimationUtils.loadAnimation(this, R.anim.welcom_alpha);

alphaAnimation.setFillEnabled(true); //启动Fill保持

alphaAnimation.setFillAfter(true);  //设置动画的最后一帧是保持在View上面

imageView.setAnimation(alphaAnimation);

alphaAnimation.setAnimationListener(this);  //为动画设置监听

}

public void onAnimationEnd(Animation animation) {

//动画结束时结束欢迎界面并转到软件的主界面

Intent intent = new Intent(this, Bluetoothoyl.class);

startActivity(intent);

this.finish();

}



public void onAnimationRepeat(Animation animation) {




// TODO Auto-generated method stub






}



public void onAnimationStart(Animation animation) {




// TODO Auto-generated method stub






}



@Override



public boolean onKeyDown(int keyCode, KeyEvent event) {



//在欢迎界面屏蔽BACK键,在退出的时候就不会返回这个欢迎页



if(keyCode==KeyEvent.KEYCODE_BACK) {



return false;



}



return false;



}

}

anim:

<set xmlns:android=”http://schemas.android.com/apk/res/android”

android:interpolator=”@android:anim/accelerate_interpolator”>

<alpha

android:fromAlpha=”0.0″

android:toAlpha=”1.0″

android:duration=”500″

/>

<alpha

android:fromAlpha=”1.0″

android:toAlpha=”0.2″

android:startOffset=”1000″

android:duration=”300″

/>

</set>



版权声明:本文为oyldianzi原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。