LoginSignup
28
29

More than 5 years have passed since last update.

アンドロイドアプリのスプラッシュ画面の実装例

Posted at

アプリを起動したら最初にロゴなどが少しの間だけ表示(スプラッシュ画面(Splash))されて画面が切り替わることがありますが、そのandroid版の実装例です。

SplashActivity.java
package com.andeight.splash.activity

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.andeight.splash.R;

public class SplashActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash_layout);
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                startActivity(intent);
                finish();
            }
        }, 2000);
    }
}
splash_layout.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:background="@android:color/white"
    android:gravity="center"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/company_logo" />

</LinearLayout>
28
29
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
29