Android display GIF images

Source: Internet
Author: User

Images in gif format are not supported in android, but because I want to have a villain in my program loading, it indicates that the image is being loaded. This villain is a GIF image. That is, you want to load the GIF image as soon as the program starts. I found some methods on the Internet, but I don't know whether the android version I used is high (android4.4) or what is the problem. Finally, I figured out a way to load it. This method is to put the gif in webView for display.

The following code is about this:

Activity_prepare_fullscreen.xml File

<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 = "loading... please wait ..."
Android: textColor = "#33b5e5"
Android: textSize = "30sp"
Android: textStyle = "bold"/>

</RelativeLayout>

PrepareFullscreenActivity. java File

If it is unnecessary, it will not be pasted. This is the main two sentences.

Private WebView runWebView = null;

RunWebView = (WebView) findViewById (R. id. runWebView );

The next sentence is put into a file, which is put under assents.

RunWebView. loadDataWithBaseURL (null, "<HTML> <body bgcolor = '# f3f3f3'> <div align = center> </div> </body>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.