Android studio to load gif files using ImageView

Using an open source image loading and caching framework of third-party Android Glide.

A first download the jar package.

https://github.com/bumptech/glide/releases/download/v3.6.0/glide-3.6.0.jar

The jar package into the libs folder, and then lead into the project.

Second, the gif file into the folder drawable

Three, then add the following code layout

    <ImageView
        android:id="@+id/welcome_gif"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"/>

among them,

 android:scaleType="fitXY"

 In order to adapt to the screen, to fill the entire screen, android: scaleType there are many other values.

 Fourth, the corresponding Activity added in the following code onCreate

        ImageView welcome_gif = (ImageView) findViewById(R.id.welcome_gif);
        Glide.with(this).load(R.drawable.welcome_mutouren).into(welcome_gif);

 

 Which, R.id.welcome_gif is ImageView's id number; R.drawable.welcome_mutouren  is placed in a gif file

 (Ui pictures from China)

 

 

 Blog Reference: https://blog.csdn.net/zhangphil/article/details/45535693

Guess you like

Origin www.cnblogs.com/lyw-hunnu/p/12151807.html