Github

Github 好用分享Android FancyGifDialog-Android(GIF對話框)

1.先導入函示庫(build.gradle: Project)

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

2.先導入函示庫(build.gradle: Module)

dependencies {
   implementation 'com.github.Shashank02051997:FancyGifDialog-Android:1.2'
}

3.程式碼範例

a.layout

 <Button
        android:id="@+id/open"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="開啟對話框"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

b.創建對話框

 open.setOnClickListener {
            FancyGifDialog.Builder(this)
                .setTitle("我是標題")
                .setMessage("我是訊息")
                .setNegativeBtnText("取消")
                .setPositiveBtnText("確定")
                .setNegativeBtnBackground("#ff0000")
                .setPositiveBtnBackground("#ff00ff")
                .setGifResource(R.drawable.giphy)
                .isCancellable(false)
                .OnPositiveClicked {
                    Toast.makeText(this, "確定", Toast.LENGTH_SHORT).show()
                }
                .OnNegativeClicked {
                    Toast.makeText(this, "取消", Toast.LENGTH_SHORT).show()
                }.build()
        }

4.效果展示

發表迴響