簡體   English   中英

無法在 Android 應用程序中顯示動畫 gif 圖像

[英]Failed to show animated gif image in android app

我正在嘗試在我的應用中顯示 .gif 圖像。 但它不起作用,那里沒有任何顯示。 我也依賴添加了 glide 庫。 我現在該怎么辦?

這是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>

嘗試使用Glide .asGif()方法在Imageview加載 gif

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM