如何在 ImageView 中显示动画 GIF
How to Display Animated GIF in ImageView
如何在 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" />
使用这个库
编译'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" />
试试这个:
"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()
}
我刚刚使用了这段代码及其工作原理
首先添加库
编译'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"/>
如何在 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" />
使用这个库
编译'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" />
试试这个:
"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()
}
我刚刚使用了这段代码及其工作原理 首先添加库
编译'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"/>