2017-01-27 19 views
0

Ich möchte meine animierte GIF-Bild in voller Größe auf dem Begrüßungsbildschirm zeigen, aber es funktioniert nicht. Ich habe auch match parent verwendet. Was ist das Problem hier? Meine XML-Datei ist:Animierte Splash-Screen Android

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_splashscreen" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.foodie.splash.splashscreen"> 


    <com.felipecsl.gifimageview.library.GifImageView 
     android:id="@+id/gifImageView" 
     android:scaleType="fitCenter" 
     android:layout_width="match_parent" 

     android:layout_marginRight="0dp" 
     android:layout_marginLeft="0dp" 
     android:layout_height="match_parent" /> 



</RelativeLayout> 

Und das ist, wie es aussieht:

its in only middle but i want in whole page

Java-Code:

package com.example.foodie.splash; 

import android.content.Intent; 
import android.os.Handler; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.widget.ProgressBar; 

import com.felipecsl.gifimageview.library.GifImageView; 

import org.apache.commons.io.IOUtils; 

import java.io.IOException; 
import java.io.InputStream; 

public class splashscreen extends AppCompatActivity { 

    private GifImageView gifImageView; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_splashscreen); 

     gifImageView = (GifImageView)findViewById(R.id.gifImageView); 

     //Set GIFImageView resource 
     try{ 
      InputStream inputStream = getAssets().open("foodie.gif"); 
      byte[] bytes = IOUtils.toByteArray(inputStream); 
      gifImageView.setBytes(bytes); 
      gifImageView.startAnimation(); 
     } 
     catch (IOException ex) 
     { 

     } 

     //Wait for 3 seconds and start Activity Main 
     new Handler().postDelayed(new Runnable() { 
      @Override 
      public void run() { 
       splashscreen.this.startActivity(new Intent(splashscreen.this,MainActivity.class)); 
       splashscreen.this.finish(); 
      } 
     },5000); // 3000 = 3second 



    } 
} 
+0

Ich möchte dieses gif in ganze Seite wie intro.pls Hilfe zeigen. –

+0

Zeigen Sie Ihren Java-Code, wo Sie gif in gifView setzen –

+0

@somumkhan: versuchen Android: scaleType = "FIT_XY" anstelle von Android: scaleType = "fitCenter" –

Antwort

1

Sie wählen einen falschen Staffelart, Einst die Scaletype als FitXY anstelle von fit center aber natürlich führen sie dazu, die skalen zu ändern, herauszufinden, ob es so etwas wie centerCrop hat.

<com.felipecsl.gifimageview.library.GifImageView 
    android:id="@+id/gifImageView" 
    android:scaleType="fitXY" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 
+0

Können Sie mir sagen, warum Sie 'marginRight =" 0dp "' und 'marginLeft =" 0dp "' in Ihrer Antwort verwenden? –

+0

@Charuka nur zur Klarstellung, es ist das gleiche wie keine –

+0

wenn es wie keiner ist, was der Punkt der Aussage gibt es keine? –

Verwandte Themen