2017-02-15 5 views

答えて

1

を見てみましょう:あなたはDrawableのXMLを作成して実際にhttps://www.bignerdranch.com/blog/splash-screens-the-right-way/

を、何かのように:あなたのスタイル値で次に

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:drawable="@color/gray"/> 
    <item> 
     <bitmap android:gravity="center" android:src="@mipmap/ic_launcher"/> 
    </item> 
</layer-list> 

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar"> 
    <item name="android:windowBackground">@drawable/background_splash</item> 
</style> 

新しいアクティビティ(空白)を作成して開始アクティビティにする(Android Manifeで) st):

<activity 
    android:name=".SplashActivity" 
    android:theme="@style/SplashTheme"> 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 

     <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
</activity> 

Teh 'SplashActivity'はあなたのMainActivityに転送する必要があります。次のようなものです:

public class SplashActivity extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     Intent intent = new Intent(this, MainActivity.class); 
     startActivity(intent); 
     finish(); 
    } 
} 

ビューをまったく膨張させないことに注意してください。作業を行うには、styleのウィンドウの背景を使用します。

関連する問題