Skip to content Skip to sidebar Skip to footer

How To Display Gif On Android Device

I'm trying to display gif images on Android. I found this code on SO, which is said a correct solution by some users : webView wView = new webView(this); wView.loadUrl('file:/

Solution 1:

Android has some basic requirements. All .gif / videos and custom fonts or (.otf) files must be only placed in assets folder. There is no other way of doing it as far as I know. To access the asset's files you have write a line of code :

The Format to access the Resource is as follows:

    "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()
       }

Post a Comment for "How To Display Gif On Android Device"