Remove a Paint Flag in Android

Viewed 36888

My code looks like this:

    TextView task_text = (TextView) view.findViewById(R.id.task_text);
    task_text.setPaintFlags( task_text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

This causes a strike through effect to appear on the text. However, I'd like to know how to remove the flag once set, and how to detect that the flag is set.

I understand this is a bitwise operation, but I've tried both ~ and - operators, neither work.

10 Answers

In Kotlin

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

TextView details_actual_price; //and find id from your xml file

details_actual_price.setPaintFlags(details_actual_price.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

//used for adapter calss

Textview details_actual_price; // and find id holder.actulPrice.setPaintFlags(holder.actulPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

I tried using the above mentioned methods in kotlin using kotlin bitwise operators and I was getting weird results...

so to remove a flag I just did

view.paintflags = 0x00

In Kotlin: numberTextView?.paintFlags = Paint.STRIKE_THRU_TEXT_FLAG to remove numberTextView?.paintFlags = Paint.STRIKE_THRU_TEXT_FLAG and Paint.STRIKE_THRU_TEXT_FLAG.inv()

Related