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

时间:2012-05-13 09:13:52

标签: android image splash-screen

我正在开发一个Android应用程序,我想要一个默认图片。这在iPhone应用程序中很常见;当应用程序启动时,它会显示开发人员的名称以及带有图像的应用程序名称(例如)。

我认为这是可能的,因为像Facebook这样的应用程序在应用程序启动之前会有这些默认屏幕。我该如何实现这些?

2 个答案:

答案 0 :(得分:3)

答案 1 :(得分:3)

在发布活动的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();
    }

您的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>

这将在应用程序启动时显示welcomescreenpicture 5秒钟。