一般一个软件刚打开时,并不是直接就显示了程序的主界面,而是先显示欢迎界面之后停留几秒,在跳转到主界面!这样实现的效果就不再多说!!下面来看一下我项目中所用到的一个欢迎界面项目实例:
上述实现的代码如下:
MainActivity.java
public class MainActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new CountDownTimer(3000,1000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
Intent intent = new Intent();
intent.setClass(MainActivity.this, MainActivity1.class);
startActivity(intent);
int VERSION=Integer.parseInt(android.os.Build.VERSION.SDK);
if(VERSION >= 5){
MainActivity.this.overridePendingTransition(R.www.alpha_in, R.www.alpha_out);
}
finish();
}
}.start();
}
}
activity_main.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="@drawable/t1"
>
</RelativeLayout>
www文件夹位于res下面,www文件夹下有两个xml文件alpha_qin,alpha_out
alpha_in.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="2000"
></alpha>
</set>
alpha_out.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="2000"
></alpha>
</set
此项目实例的代码是利用了网络上的资源!!!!!想在此分享给更多的人!!!!希望对大家有帮助!!!!