簡體   English   中英

是否有任何用 Kotlin 編寫的 android 的 GIF 庫 [擱置]

[英]Is there any GIF library for android written in Kotlin [on hold]

我想在我的項目中使用gif圖像,但問題是我想要在Kotlin而不是java中。

你可以試試這個用 Kotlin 寫的庫,我不是作者: AndroidGifViewPlayerKotlin

步驟 1. 將其添加到存儲庫末尾的根 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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM