如何从远程视图中删除文本删除。
这是我的代码,但它不起作用 -
通过文字添加警示(工作) -
views.setInt(R.id.widgetTitle, "setPaintFlags", Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
通过文字删除警示(不工作) -
views.setInt(R.id.widgetTitle, "setPaintFlags", Paint.STRIKE_THRU_TEXT_FLAG & (~Paint.ANTI_ALIAS_FLAG));
完整代码 -
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));
}
答案 0 :(得分:0)
你不需要" unstrikethrough" TextView
,如果您想要普通文本(仅因为Paint.ANTI_ALIAS_FLAG
不添加新标记和之前的标记,只需设置setPaintFlags()
即可,只需设置新标志):
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);
}
如果你想保留多个先前在删除删除线效果时设置的标记,我想指出这个post by edwoolard