Android 小部件 - 如何从远程视图中删除删除线
Android widget - How to remove text strike through from remote view
如何从远程视图中删除删除线。
这是我的代码,但它不起作用 --
在文本中添加删除线(有效)-
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));
}
您不需要 "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
如何从远程视图中删除删除线。
这是我的代码,但它不起作用 --
在文本中添加删除线(有效)-
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));
}
您不需要 "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