2016-08-26 17 views
3

Ich habe den Code wie folgt in meiner Android App.Android Splash-Screen zeigt nicht Bild Vollbild

Meine res/Werte/styles.xml:

<style name="FullScreen" parent="@style/Theme.AppCompat.Light"> 
    <item name="windowNoTitle">true</item> 
    <item name="windowActionBar">false</item> 
    <item name="android:windowFullscreen">true</item> 
    <item name="android:windowContentOverlay">@null</item> 
    <item  name="android:windowBackground">@drawable/background_splash</item> 
    </style> 

res/ziehbar/background_splash.xml:

<item 

    android:drawable="@color/colorPrimaryDark"/> 

    <item> 
     <bitmap 
     android:gravity="center" 
     android:src="@mipmap/image1"/> 
    </item> 

AndroidManifest.xml:

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

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

SplashActivity.java:

public class SplashActivity extends AppCompatActivity { 

    private static int SPLASH_TIME_OUT = 5000; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    //setContentView(R.layout.activity_splash); 

    new Handler().postDelayed(new Runnable() { 

     @Override 
     public void run() { 
      Intent i = new Intent(SplashActivity.this, MainActivity.class); 
      startActivity(i); 
      finish(); 
     } 
     }, SPLASH_TIME_OUT); 
     } 
    } 

Ich habe das Image1 mit entsprechender Auflösung/Größe im Ordner res. Der Begrüßungsbildschirm zeigt jedoch nicht das Bild an, das den ganzen Bildschirm abdeckt, sondern nur einen Teil des Bildschirms. Können Sie bitte beraten, was zu tun ist? Ich habe einige der Vorschläge auf einigen Websites durchgesehen, aber es hat nicht geholfen.

+1

bitte xml posten und sicher Imageview Eigenschaft machen 'SCROLL =„fitXY“' .... – sushildlh

+1

Teilen Screenshot Ihres Splash-Screen –

+0

Wie poste ich ein Bild zu diesem Kommentar-Box? Entschuldigung, ich bin ein Neuling, um Überlauf zu stapeln. schätzen Sie Ihre Antwort. – dacscan3669

Antwort

0

Verwendung Elternteil Thema

parent = "@ style/Theme.AppCompat.Light.NoTitleBar.Fullscreen"

0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 
<ImageView android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:src="@drawable/image" /> 
</LinearLayout 

Und

this.requestWindowFeature(Window.FEATURE_NO_TITLE); 

in Ihrem Aktivitätscode verwenden.

+0

Ich habe versucht, die obige Lösung, aber es füllt immer noch den gesamten Bildschirm. – dacscan3669

+0

Geht oder nicht? – Niroj

+0

android: theme = "@ android: style/Theme.Light.NoTitleBar.Fullscreen" oder Sie können dies in Ihrem Manifest unter activity tag hinzufügen .. – Niroj

0

Stellen Sie sicher, dass Ihre Splash-XML-Datei kein Padding hat. Falls vorhanden, löschen.

3

Ich habe dieses Programm durchgeführt. Suchst du danach? dies ist Ihre Haupt-XML-

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res 
/android" 
android:layout_width="match_parent" 
android:background="@drawable/android" 
android:layout_height="match_parent"> 

Und mainActivity

public class MainActivity extends AppCompatActivity { 
// Splash screen timer 
private static int SPLASH_TIME_OUT = 3000; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    new Handler().postDelayed(new Runnable() { 

     /* 
     * Showing splash screen with a timer. This will be useful when you 
     * want to show case your app logo/company 
     */ 

     @Override 
     public void run() { 
      // This method will be executed once the timer is over 
      // Start your app main activity 
      Intent i = new Intent(MainActivity.this, YourNextActivity.class); 
      startActivity(i); 

      // close this activity 
      finish(); 
     } 
    }, SPLASH_TIME_OUT); 
}} 

Und Manifestieren

<activity android:name=".MainActivity"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" 
       android:theme ="@android:style/Theme.Black.NoTitleBar.Fullscreen"/> 

      <category android:name="android.intent.category.LAUNCHER" /> 
+1

Es funktioniert für mich !!! Vielen Dank !!! –

3

In Ihrem res/ziehbar/background_splash.xml, ändern android: Schwerkraft Sie können "fill" verwenden, in meinem Fall habe ich "top | fill_horizontal" nur für horizontale Füllung verwendet, wählen Sie die gewünschte Kombination aus.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 

    <item android:drawable="@color/White"/> 

    <item> 
     <bitmap 
      android:gravity="center" 
      android:src="@drawable/splash"/> 
    </item> 
</layer-list> 
+1

Danke @Jose genau das, was ich gesucht habe. –

+0

wenn Auflösung des Bildes ist weniger als Bildschirm dann funktioniert es nicht –

+0

Nun, ich habe es nicht versucht, aber, ich empfehle nicht, mit kleineren Bildern zu füllen –