Play.gif image in android without using webview

前端 未结 1 588
攒了一身酷
攒了一身酷 2021-01-07 10:23

I tried like this, which i found on the net to play gif images:

private class MYGIFView extends View {

    Movie movie;
    InputStream is = null;
    long          


        
相关标签:
1条回答
  • 2021-01-07 11:07

    Android cannot play GIF files without WebView. You must break it apart into frames and animate it yourself.

    I found on another StackOverflow post this bit of software from XoyoSoft, called GifSplitter, that can split a GIF into frames. You would then want to use AnimationDrawable to combine those.

    It would look something like this:

    // Your files:
    res\drawable-xxxx\frame1.jpg
    res\drawable-xxxx\frame2.jpg
    res\drawable-xxxx\frame3.jpg
    // ...
    res\drawable-xxxx\frame99.jpg
    

    Then, there is an example in the AnimationDrawable documentation above that will show how to display those images.

    Lastly, you must load and play the animation; that, too, is detailed in the AnimationDrawable documentation.

    0 讨论(0)
提交回复
热议问题