2017-10-11 83 views
-2

我試圖在我的應用程序中顯示.gif圖像。但它不起作用,沒有任何顯示。我也在依賴中添加了滑行庫。我現在應該怎麼做?未能在Android應用程序中顯示動畫GIF圖像

這裏去VegetableActivity.java文件

public class VegetableActivity extends Activity{ 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_vegetable); 
     ImageView load_Image = (ImageView)findViewById(R.id.load_Image); 

     Glide.with(this) 
       .load("https://media.giphy.com/media/m80Q4HTDNPFHq/giphy.gif") 

       .into(load_Image); 


    } 
} 

這裏去佈局xml文件activity_vegetable.xml

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 

    android:id="@+id/activity_vegetable" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.emma.kidbox.VegetableActivity"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="THIS IS AN EXAMPLE OF GLIDE LIBRARY IN ANDROID" 
     android:fontFamily="sans-serif-condensed" 
     android:id="@+id/textView" 
     android:textSize="30dp"/> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/load_Image" 
     android:layout_below="@+id/textView" 
     android:layout_centerHorizontal="true"/> 

</LinearLayout> 
+0

試試這個https://stackoverflow.com/a/31128 019/8089770 –

+2

[使用Glide顯示GIF文件(圖像加載和緩存庫)]可能的重複](https://stackoverflow.com/questions/31082330/show-gif-file-with-glide-image-loading-and-緩存庫) –

+1

[在Android中ImageView中添加gif圖像](https://stackoverflow.com/questions/6533942/adding-gif-image-in-an-imageview-in-android) – sushildlh

回答

0

嘗試這種使用Glide.asGif()方法加載GIF Imageview

Glide.with(this) 
    .load("https://media.giphy.com/media/m80Q4HTDNPFHq/giphy.gif") 
    .asGif() 
    .into(load_Image);