Remove a Paint Flag in Android

To remove a flag, this should work:

task_text.setPaintFlags( task_text.getPaintFlags() & (~ Paint.STRIKE_THRU_TEXT_FLAG));

Which means set all the set flags, except of Paint.STRIKE_THRU_TEXT_FLAG.

To check if a flag is set (Edit: for a moment I forgot it is java...):

if ((task_text.getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) > 0)

In Kotlin

task_text.paintFlags = task_text.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()

This also works:

task_text.setPaintFlags(0);

Use exclusive OR operator ^ instead of | with &(~) combination:

// setup STRIKE_THRU_TEXT_FLAG flag if current flags not contains it
task_text.setPaintFlags(task_text.getPaintFlags() ^ Paint.STRIKE_THRU_TEXT_FLAG));

// second call will remove STRIKE_THRU_TEXT_FLAG
task_text.setPaintFlags(task_text.getPaintFlags() ^ Paint.STRIKE_THRU_TEXT_FLAG));

Check if flag is currently setup:

if((task_text.getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) == Paint.STRIKE_THRU_TEXT_FLAG)