calculateContrast

open fun calculateContrast(@ColorInt foreground: Int, @ColorInt background: Int): Double(source)

Returns the contrast ratio between foreground and background. background must be opaque.

Formula defined here.