启动图启动界面的简单实现

一、Android App启动图启动界面的简单实现

 

1.activity实现

创建一个Splash activity

public class Splash extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate( savedInstanceState);
        //加载启动界面
        setContentView(R.layout.activity_splash);
        Integer time = 2000;    //设置等待时间,单位为毫秒
        Handler handler = new Handler();
        //当计时结束时,跳转至主界面
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(new Intent(Splash.this, MainActivity.class));
                Splash.this.finish();
            }
        }, time);
    }

}

2.xml实现

对应一个xml,我直接把图片作为背景处理,这样可以直接将图片裁剪好,不用另外处理。

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/pika"
    >
</LinearLayout>

3.修改配置文件AndroidManifest中的代码

去Androidmanife设置最先加载

        <activity android:name=".Splash"
                   android:theme="@style/FixSystemWindowTheme">    

去style里去除titlebar实现全屏效果

<style name="FixSystemWindowTheme" parent="AppTheme">
    <item name="android:windowFullscreen">true</item>
    <item name="windowNoTitle">true</item>
    </style>

最后,效果图

 

转:https://www.jianshu.com/p/84fdde25a0f7

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章