android studio中使用android-gif-drawable开源项目实现gif图片的显示

xiaoxiao2021-02-28  75

android-gif-drawable开源库地址:https://github.com/koral–/android-gif-drawable 将该页面上的如下代码添加到build.gradle中即可 然后就可以直接在布局文件中使用pl.droidsonroids.gif.GifImageView等组件 效果如图

build.gradle中代码如下

apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "com.guet.giftest" minSdkVersion 19 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } buildscript { repositories { mavenCentral() } } allprojects { repositories { mavenCentral() } } repositories { mavenCentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots" } } dependencies { compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.+' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' testCompile 'junit:junit:4.12' compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.7' }

布局代码如下,src中是gif图路径

<pl.droidsonroids.gif.GifImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/dd"/>
转载请注明原文地址: https://www.6miu.com/read-74208.html

最新回复(0)