android 顯示gif圖片實(shí)例詳解
在android中不支持gif格式的圖片,但是由于我希望在我的程序中剛剛加載的時(shí)候有一個(gè)小人在跑步表示正在加載。而這個(gè)小人跑就是一個(gè)gif圖片。也就是希望程序一啟動(dòng)時(shí)就加載gif圖片。在網(wǎng)上查找了一些方法不知道是我使用的android的版本高(android4.4)還是什么問題就是加載不出來。最后想了一個(gè)辦法加載了出來。這個(gè)辦法就是將gif放在webView中讓其顯示。
下面是關(guān)于這個(gè)的代碼:
activity_prepare_fullscreen.xml文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#F3F3F3" > <WebView android:id="@+id/runWebView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" /> <TextView android:id="@+id/fullscreen_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/runWebView" android:layout_centerHorizontal="true" android:gravity="center" android:keepScreenOn="true" android:text="正在加載請等待..." android:textColor="#33b5e5" android:textSize="30sp" android:textStyle="bold" /> </RelativeLayout>
PrepareFullscreenActivity.java 文件
多余的就不貼了,這是主要的兩句
private WebView runWebView=null;
runWebView = (WebView) findViewById(R.id.runWebView);
下一句就是放入文件,文件在assents下放著呢
runWebView.loadDataWithBaseURL(null,"<HTML><body bgcolor='#f3f3f3'><div align=center><IMG src='file:///android_asset/run.gif'/></div></body></html>", "text/html", "UTF-8",null);
希望通過本文,能幫助大家解決這種問題,謝謝大家對本站的支持!
相關(guān)文章
Android ADT和SDK Manager無法更新下載解決方案
這篇文章主要介紹了Android ADT和SDK Manager無法更新下載解決方案的相關(guān)資料,需要的朋友可以參考下2017-04-04解析如何在android中增加gsensor驅(qū)動(dòng)(MMA7660)
本篇文章是對在android中增加gsensor驅(qū)動(dòng)(MMA7660)進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06Android編程之SurfaceView實(shí)例詳解
這篇文章主要介紹了Android編程之SurfaceView用法,簡要分析了View和SurfaceView的區(qū)別,并結(jié)合實(shí)例形式分析了SurfaceView的具體使用步驟與相關(guān)技巧,需要的朋友可以參考下2016-02-02Android菜單的定義及ActionBar的實(shí)現(xiàn)
本篇文章主要介紹了Android菜單的定義及ActionBar的實(shí)現(xiàn),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-08-08