How to remove text strike through from remote view.
Here is my code, but it is not working --
To add strike through text(working) -
views.setInt(R.id.widgetTitle, "setPaintFlags", Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
To remove strike through text (not working)-
views.setInt(R.id.widgetTitle, "setPaintFlags", Paint.STRIKE_THRU_TEXT_FLAG & (~Paint.ANTI_ALIAS_FLAG));
Full code -
if (item.isCheck()) {
views.setTextColor(R.id.widgetTitle, Color.WHITE);
views.setInt(R.id.widgetTitle, "setPaintFlags", Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
} else {
views.setTextColor(R.id.widgetTitle, Color.WHITE);
views.setInt(R.id.widgetTitle, "setPaintFlags", Paint.STRIKE_THRU_TEXT_FLAG & (~Paint.ANTI_ALIAS_FLAG));
}
You don't need to "unstrikethrough" the TextView
, it is sufficient to simply set the Paint.ANTI_ALIAS_FLAG
if you want normal text (that's because setPaintFlags()
does not add the new and the previous flags, it just sets the new flags):
if (item.isCheck()) {
views.setTextColor(R.id.widgetTitle, Color.WHITE);
views.setInt(R.id.widgetTitle, "setPaintFlags",
Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
} else {
views.setTextColor(R.id.widgetTitle, Color.WHITE);
views.setInt(R.id.widgetTitle, "setPaintFlags", Paint.ANTI_ALIAS_FLAG);
}
If you want to preserve more than one flag which was previously set while removing the strikethrough effect, I'd like to point you to this post by edwoolard
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.