instagram style image picker
- The image returns uri path as a cropped shooting image.
dependencyResolutionManagement {
repositories {
...
maven("https://jitpack.io")
}
}
dependencies {
implementation ("com.github.kimyuhyun:KyhImagePicker2:1.0.4")
}
- Insert the code below into the button to run the image picker.
findViewById<Button>(R.id.btn_open_gallery).setOnClickListener {
CoroutineScope(Dispatchers.Main).launch {
val result = KyhImagePicker2.of(this@MainActivity)
.setTitle("Title")
.setLimitCount(5)
.setLimitMessage("Limit")
.setNoSelectedMessage("no selected")
.open()
Log.d("####", "$result")
if (result != null) {
for (i in result.indices) {
when (i) {
0 -> findViewById<ImageView>(R.id.iv_0).setImageURI(result[i])
1 -> findViewById<ImageView>(R.id.iv_1).setImageURI(result[i])
2 -> findViewById<ImageView>(R.id.iv_2).setImageURI(result[i])
3 -> findViewById<ImageView>(R.id.iv_3).setImageURI(result[i])
4 -> findViewById<ImageView>(R.id.iv_4).setImageURI(result[i])
}
}
}
}
}