Github

Github 好用分享Android ColorPicker(顏色選擇器)

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

dependencies {
   implementation 'com.github.dhaval2404:colorpicker:1.1'
}

2.程式碼範例

a.layout聲明com.github.dhaval2404.colorpicker.ColorPickerView

<com.github.dhaval2404.colorpicker.ColorPickerView
    android:id="@+id/colorPick"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

b.實作ColorListener

colorPick.setColorListener { colorInt, colorHex ->
     Toast.makeText(this, "colorIntcolorHex", Toast.LENGTH_SHORT).show()
     add.setBackgroundColor(colorInt)
 }

4.效果展示

發表迴響