【问题标题】:How to Display Animated GIF in ImageView [closed]如何在 ImageView 中显示动画 GIF [关闭]
【发布时间】:2017-02-24 06:31:32
【问题描述】:

如何在 Imageview 中显示动画 Gif 我使用了 Drawable 文件夹中的 Gif,它不像 Gif 那样显示。求各位帮忙

这是我的 Imageview 代码

    <ImageView
            android:layout_width="40dp"
            android:id="@+id/ivGif"
            android:src="@drawable/success_bg"
            android:layout_height="40dp"
            android:gravity="center|bottom"
            android:visibility="visible" />

【问题讨论】:

标签: android animated-gif


【解决方案1】:

使用这个库

编译'pl.droidsonroids.gif:android-gif-drawable:1.2.3'

<pl.droidsonroids.gif.GifImageView
        android:id="@+id/gif_iv"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:scaleType="centerCrop"
        android:src="@drawable/ic_ani_gif"
        app:layout_anchor="@+id/rl_holder_view"
        app:layout_anchorGravity="center|top" />

【讨论】:

    【解决方案2】:

    我刚刚使用了这段代码及其工作 首先添加库

    编译'pl.droidsonroids.gif:android-gif-drawable:1.2.3'

    然后像这样设置 gif 布局你想放 gif 的地方

    <pl.droidsonroids.gif.GifTextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/your_gif"/>
    

    【讨论】:

      【解决方案3】:

      试试这个:

       "android.resource://[package]/[res id]"
      
          Uri myUri =("android.resource://" + context.getPackageName() + "/"
                              + R.drwable.mygifimage);
          try{
              Url myUrl = myUri.toURL();
              webView wView = new webView(this);   
              wView.loadUrl(myUrl);
              setContentView(view);
      
             }catch(Exception e){
                    e.printStackTrace()
             }
      

      【讨论】:

        猜你喜欢
        • 2015-03-15
        • 2017-11-10
        • 1970-01-01
        • 2019-01-04
        • 2013-05-04
        • 2021-05-13
        • 2016-06-06
        相关资源
        最近更新 更多