是否有用Kotlin编写的android GIF库

问题描述 投票:-1回答:1

我想在我的项目中使用gif图像,但问题是我希望在Kotlin中使用此java中的[[not。

java android kotlin gif
1个回答
0
投票
您可以尝试用Kotlin编写的这个库,我不是作者:AndroidGifViewPlayerKotlin

步骤1.将其添加到存储库末尾的root build.gradle中:

allprojects { repositories { ... maven { url 'https://jitpack.io' } } }

步骤2.添加依赖项

dependencies { implementation 'com.github.harunkor:AndroidGifViewPlayerKotlin:1.0.0' }

布局:

<tr.com.harunkor.gifviewplayer.GifMovieView android:id="@+id/gifViewPlayer" android:layout_width="400dp" android:layout_height="400dp"/>

代码:

//gif player layout variable. var gifViewPlayer: GifMovieView? = findViewById(R.id.gifViewPlayer) as GifMovieView //gif animation file set in drawable folder. gifViewPlayer!!.setMovieResource(R.drawable.carkifelek) //gif animation Movie callback and set gifViewPlayer?.setMovie(gifViewPlayer?.getMovie()!!); // gif animation hide. gifViewPlayer?.setVisibility(View.INVISIBLE); // gif animation visible gifViewPlayer?.setVisibility(View.VISIBLE); // gif animation file set in assets folder. gifViewPlayer?.setMovieAssets("eat.gif"); var path:String = Environment.getExternalStorageDirectory().toString() + "/Download/danc.gif"; // gif animation file set in Android device. gifViewPlayer?.setMovieFile(path); // gif animation (URL stream) show link. gifViewPlayer?.setMovieUrl("https://scdn.androidcommunity.com/wp-content/uploads/2014/10/androidify2.gif"); // gif animation pause gifViewPlayer?.setPaused(true); // gif animation play gifViewPlayer?.setPaused(false);

© www.soinside.com 2019 - 2024. All rights reserved.