2017-10-11 81 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);