a = (color shr 24) and 0xff val r = (color shr 16) and 0xff val g = (color shr 8) and 0xff val b = color and 0xff val color = Color.CYAN val a = color.alpha val r = color.red val g = color.green val b = color.blue
Any?>) = Bundle(pairs.size).apply { for ((key, value) in pairs) { when (value) { null -> putString(key, null) // Any nullable type will suffice. // Scalars is Boolean -> putBoolean(key, value) is Byte -> putByte(key, value) is Char -> putChar(key, value) is Double -> putDouble(key, value) is Float -> putFloat(key, value) ...
jumped over the lazy dog") sb.setSpan(ForegroundColorSpan(Color.RED), 0, 3, 0) sb.setSpan(StyleSpan(Typeface.ITALIC), 8, 14, 0) sb.setSpan(StyleSpan(Typeface.BOLD), 24, 28, 0) Red fox jumped over the lazy dog Bad
ForegroundColorSpan(Color.RED)) .append(" fox ") .append("jumped", StyleSpan(Typeface.ITALIC)) .append(" over the ") .append("lazy", StyleSpan(Typeface.BOLD)) .append(" dog") Red fox jumped over the lazy dog Better
do something } textView.doBeforeTextChanged { text, start, count, after -> // do something } textView.doOnTextChanged { text, start, count, after -> // do something }