I'm trying to remove the underlining of text from my button. This is the code, where I underline it:
buttonNews.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
I also don't understand why someone put button.getPaintFlags()
inside the brackets, it works fine with the code above:
button.setPaintFlags(button.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
Would you please advice how to remove the underlining of the text inside the button programatically?
They put button.getPaintFlags()
inside the brackets, to not lose the default/old flag(s).
To remove the UNDERLINE_TEXT_FLAG
flag, you can do:
button.setPaintFlags( button.getPaintFlags() & (~ Paint.UNDERLINE_TEXT_FLAG));
This will set all the old flags except Paint.UNDERLINE_TEXT_FLAG
.