简体   繁体   English

如何将默认图片放入android? (启动画面)

[英]How I do to put the default picture in android? (Splash-screen)

I'm developing an android application and I want to put a default picture. 我正在开发一个android应用程序,我想放一张默认图片。 This is common in iPhone apps; 这在iPhone应用程序中很常见; when the app starts, it shows the name of the developer and the name of the application (for example) with an image. 当应用程序启动时,它会显示开发人员的姓名和带有图像的应用程序的名称(例如)。

I think that is possible because apps like Facebook have these default screens before the application starts. 我认为这是可能的,因为像Facebook这样的应用程序在应用程序启动之前具有这些默认屏幕。 How can I implement these? 如何实施这些?

In your onCreate() method of your launch activity, try this: 在启动活动的onCreate()方法中,尝试执行以下操作:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Thread proceed = new Thread(){

        public void run()
        {
            try {
                sleep(5000);
                Intent next = new Intent("nextActivityIntentGoesHere");
                startActivity(next);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            finally{
                finish();
            }

        }
        };
        proceed.start();
    }

Your main.xml can be as follows: 您的main.xml可以如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/welcomescreenpicture" >
</LinearLayout>

This will display the welcomescreenpicture for 5 seconds when the application launches. 启动应用程序时,这将在5秒钟内显示welcomescreenpicture屏幕图片。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM