Todoリストを作っていて特定の条件下で取り消し線と色を変えるために調べていたので備忘録
object AlreadyReadEffect {
fun invoke(textView: TextView, checked: Boolean) {
if (checked) {
textView.apply {
setTextColor(Color.LTGRAY)
paint.flags = this.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
paint.isAntiAlias = true
}
} else {
textView.apply {
setTextColor(Color.BLACK)
paint.flags = Paint.ANTI_ALIAS_FLAG
paint.isAntiAlias = false
}
}
}
}