2016-06-27 24 views
0

私はスプラッシュ画面コードで作業しているアンドロイドプロジェクトに取り組んでいますが、スプラッシュ画像はモバイルの画面全体に表示されません。 -モバイルの画面全体にスプラッシュ画面が表示されない

scaleTypeをfitXYのようなものに:私は示されていた
public class SplashPresenter extends MvpBasePresenter<SplashView> { 

    @Override public void attachView(SplashView view) { 
     super.attachView(view); 
     new Handler().postDelayed(new Runnable() { 
      @Override public void run() { 
       launch(); 
      } 
     }, 2000); 
    } 

    @Override public void detachView(boolean retainInstance) { 
     super.detachView(retainInstance); 
    } 

    private void launch() { 
     String imei = ImeiUtil.getIMEI(); 

     List<ActivationInfo> infos = ActivationInfo.listAll(ActivationInfo.class); 
     if (infos.size() == 1) { 
      ActivationInfo info = infos.get(0); 
/* 
      Log.d("I: ", "I: " + info.getBusinessName()); 
      Log.d("I: ", "I: " + info.getMobileNumber()); 
      Log.d("I: ", "I: " + info.getImei()); 
      Log.d("I: ", "I: " + imei); 
      Log.d("I: ", "S: " + info.getStatus()); 
*/ 
      if (info.getStatus() == 1 && info.getImei().equalsIgnoreCase(imei)) { 
       getView().start(HomeActivity.class); 
      } else { 
       //getView().start(ActivationActivity.class); 
      getView().start(HomeActivity.class); 
      } 
     } else { 
      getView().start(HomeActivity.class); 
     // getView().start(RegisterActivity.class); 
     } 
    } 

とXMLコードでは、ここ

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MainActivity"> 

    <ImageView 
     android:contentDescription="@string/splash_image" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:adjustViewBounds="true" 
     android:scaleType="centerCrop" 
     android:src="@drawable/splash_english"/> 

</RelativeLayout> 
+2

あなたのres/style.xmlとマニフェストファイルを表示 – Khan

+0

あなたはスクリーンショットを提供できますか? – Piyush

答えて

0

にこの行を追加します。表示されたスプラッシュビューは、スプラッシュアクティビティでレイアウトファイルを展開する前にすぐに準備ができている必要があります。レイアウトファイルを使用しません。代わりに、スプラッシュスクリーンの背景をアクティビティのテーマの背景として指定します。これを行うには、まずres/drawableにXML描画可能ファイルを作成します。これはxmlファイルです。

<?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> 

次に、これをテーマのスプラッシュアクティビティの背景として設定します。あなたのstyles.xmlファイルに移動して、スプラッシュ活動のための新しいテーマを追加します。

<resources> 

    <!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
     <!-- Customize your theme here. --> 
    </style> 

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

</resources> 

あなたSplashActivityクラスは、ちょうど前方にあなたのメインの活動に沿って必要があります。

public class SplashActivity extends AppCompatActivity { 

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

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

全体のソースコードが提供されていますダウンロードのためにここにhttps://github.com/shubhamsharmacs/Splash

0
あなたがちょうどあなたのアンドロイドを変更、画面を埋めるためにあなたのイメージを希望している場合は
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity"> 

<ImageView 
    android:contentDescription="@string/splash_image" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:adjustViewBounds="true" 
    android:scaleType="centerCrop" 
    android:src="@drawable/splash_english" 
    android:minHeight="1000dp" 
    android:minWidth="1000dp"/> 

</RelativeLayout> 
0

です。 minHeightとminWidthに依存し、centerCropを使用しても、複数のデバイスサイズでうまくカバーできません。よりよい解決策、XMLベースのDrawableをより良いサイズの画像を開発したり使用

0

活動のあなたのonCreateメソッドの正しい方法は、あなたが想像よりも少し異なってスプラッシュスクリーンを実装

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
関連する問題