有没有一种简单的方法通过文字罢工在一个应用程序窗口小部件? [英] Is there an easy way to strike through text in an app widget?

查看:132
本文介绍了有没有一种简单的方法通过文字罢工在一个应用程序窗口小部件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,如果有一个简单的方法来在Android中的应用程序插件罢工文本。在一个正常的活动,它是pretty的方便,使用TextView的标志:

I was wondering if there is an easy way to strike text within an app widget in Android. In a normal activity, it is pretty easy, using textview flags:

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

但是,由于在一个应用程序窗口小部件,我只能使用remoteviews ...我不知道这是可能的。

But since in an app widget, I can use only remoteviews... I do not know if this is possible

任何人都对此有所了解?

Anyone know something about this?

谢谢!

推荐答案

2015年更新:伙计们,这是很老版本的Andr​​oid。请参阅其他答案现代的解决办法!

2015 Update: Folks, this is for very old versions of Android. See other answers for modern solutions!

要打击整个文本视图,您可以使用特定的背景图像来模拟删除线效果:

To strike through the entire text view, you can use a specific background image to simulate the strikethrough effect:

android:background="@drawable/bg_strikethrough"

bg_strikethrough 可绘有9补丁,保持实线从中间穿过,越来越多一左一右,你认为是合理但多少填充。我用一个像这样的:

Where the bg_strikethrough drawable is a 9-patch that keeps a solid line through the middle, growing either side, with however much padding you think is reasonable. I've used one like this:

(扩大为清楚起见.. 1300%!)

(enlarged for clarity.. 1300% !)

这是我的华电国际版本,所以保存(第一个 HTTP://i.stack .imgur.com / nt6BK.png )为 RES /绘制,华电国际/ bg_strikethrough.9.png 和配置将作为这样:

That is my HDPI version, so save it (the first one http://i.stack.imgur.com/nt6BK.png) as res/drawable-hdpi/bg_strikethrough.9.png and the configuration will work as so:

这篇关于有没有一种简单的方法通过文字罢工在一个应用程序窗口小部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆