我想在当前活动中播放 GIF 文件。
我有一个 XML 文件,其中有一个布局。
我想在同一个班级的 Activity 中播放 GIF。
有没有一种简单的方法可以在 Activity 类中播放 GIF 文件?
您可以使用网络视图。
我将用一个例子来展示:
//My activity
public class Gift_Loading extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Gif_loading_View view = new Gif_loading_View(this);
setContentView(view);
}
}
//the webView
public class Gif_loading_View extends WebView{
public Gif_loading_View(Context context) {
super(context);
loadUrl("file:///android_asset/loading_position.html");
}
}
在assets文件夹中添加这个html文件:
<html>
<body bgcolor="white">
<table width="100%" height="100%">
<tr>
<td align="center" valign="center">
<br/>
<br/>
<br/>
<font size="6">Please wait...</font>
<br/>
<br/>
<img src="cyclist_loading.gif" />
</td>
</tr>
</table>
</body>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)