Display Animated GIF

后端 未结 30 2100
无人及你
无人及你 2020-11-22 02:11

I want to display animated GIF images in my aplication. As I found out the hard way Android doesn\'t support animated GIF natively.

However it can display animations

30条回答
  •  旧时难觅i
    2020-11-22 02:33

    The easy way to display animated GIF directly from URL to your app layout is to use WebView class.

    Step 1: In your layout XML

    Step 2: In your Activity

    WebView wb;
    wb = (WebView) findViewById(R.id.webView);
    wb.loadUrl("https://.......);

    Step 3: In your Manifest.XML make Internet permission

    Step 4: In case you want to make your GIF background transparent and make GIF fit to your Layout

    wb.setBackgroundColor(Color.TRANSPARENT);
    wb.getSettings().setLoadWithOverviewMode(true);
    wb.getSettings().setUseWideViewPort(true);

提交回复
热议问题