Search code examples
androidxmlandroid-layoutuser-interfaceuicolor

Force function to pick a dark shade from image instaed of Light One


I have created this function to pick color from image.


fun getMainColor(img: Bitmap): Int {
    val newImg = Bitmap.createScaledBitmap(img, 1, 1, true)
    val color = newImg.getPixel(0, 0)
    newImg.recycle()
    return color
}

But it usually chooses a Light Shade color that makes the UI so Ugly, I want it to Choose a dark shade from the image. How Could I do that!


Solution

  • Palette API is good solution for find the colors from the Image with multiple choices.