2017-02-18 1 views
-1
package cppandi.apjquotes; 

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

public class MainSplashScreen extends Activity { 

/** Duration of wait **/ 
private final int SPLASH_DISPLAY_LENGTH = 5000; 

/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.front); 

    /* New Handler to start the Menu-Activity 
    * and close this Splash-Screen after some seconds.*/ 
    new Handler().postDelayed(new Runnable(){ 
     @Override 
     public void run() { 
      /* Create an Intent that will start the Menu-Activity. */ 
      Intent mainIntent = new Intent(MainSplashScreen.this,MainActivity.class); 
      MainSplashScreen.this.startActivity(mainIntent); 
      MainSplashScreen.this.finish(); 
     } 
    }, SPLASH_DISPLAY_LENGTH); 
} 
} 

を実行している第二の活動の後に来ていることは私のfront.xmlここ私は私のアプリでスプラッシュ画面を取得しておりません、だけで空白の画面がここ

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:orientation="vertical" android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:srcCompat="@mipmap/front" 
    android:id="@+id/imageView" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 
</RelativeLayout> 

である私たManifest.xml

です
<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="cppandi.apjquotes"> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 

    <activity 
     android:name=".MainSplashScreen" 
     android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

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

    <activity android:name=".MainActivity" 
     android:label="@string/app_name"> 
    </activity> 
    <activity android:name=".quotes" 
     android:label="@string/app_name"> 
    </activity> 
    <activity android:name=".about" 
     android:label="@string/app_name"> 
    </activity> 

</application> 

それが5秒間白い画面のように表示され、それが次のアクティビティ「Mainactivitに起こっている私のAndroidアプリを開いた後y "しかし、front.xmlの画像は表示されません。

+0

でそれを置き換えることができます?これはただで5秒の遅延を与えますあなたがメインアプリに入る前にロードするものがあれば、アプリは良いではありません、スプラッシュ画面を行います。 – Redman

+0

ええ、スプラッシュ画面に表示するロゴがあります – Chitrapandi

答えて

0

この置き換えます。これにより

app:srcCompat="@mipmap/front" 

を:

android:src="@mipmap/front" 
1

はこれを試してみてください。

<ImageView 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@mipmap/front" //change this 
android:id="@+id/imageView" 
android:layout_alignParentLeft="true" 
android:layout_alignParentStart="true" /> 

srcCompat属性は、実際にAPPCOMPATライブラリ内で定義されています。ドキュメントから

アプリ:

があなたの app.Vectorのドローアブルにベクトルドローアブルを統合するために使用されsrcCompatが定義され、あなたが シングルベクタ形式で複数のPNG資産を交換することができますXMLで。以前 ロリポップと高いデバイス

アンドロイドに制限しながら:SRC

このImageView.Itの内容は 元のサイズで表示されますよう描画可能に設定します。自動スケーリングはありません。

0

アプリ:srcCompatは、ベクトルドローアブルをサポートするために使用されます。あなたはbuild.gradleファイル

android { 
     defaultConfig { 
     vectorDrawables.useSupportLibrary = true 
     } 
    } 

vectorDrawables.useSupportLibrary =真が追加されていることを確認するか、あなたは、このスプラッシュ画面が必要なのか、なぜandroid:src=

関連する問題