以下列格式显示Timer的持续时间

时间:2011-01-28 09:18:04

标签: android

我开发了一个Timer组件。目前时间显示如下:

enter image description here

我希望以下列方式显示时间,最好以特定的数字格式说明。

enter image description here

我应该在布局XML中做出哪些更改,或者我的方法应该是什么?

3 个答案:

答案 0 :(得分:1)

我认为Android中没有您想要的字体。我会直接在Canvas上绘制它。或者,您可以为每个数字创建一个基于Canvas的组件。

我认为这篇关于在Canvas上绘制Android矢量图的博客/文章可能对您有用http://www.simonhildebrandt.com/home/tipofthedayvectorrenderinginandroid

答案 1 :(得分:0)

你给出的格式是不可见的......虽然你可以这样做:

SimpleDateFormat stf = new SimpleDateFormat(“hh:mm a”); System.out.println(“时间是”+ stf.format(cal.getTime()));

这将以12小时格式打印,提及Am / PM。

SimpleDateFormat stf = new SimpleDateFormat(“HH:mm:ss”);

这将使其成为24小时格式。

答案 2 :(得分:0)

我不确定,但我认为你将有2个使用图像。如果您只是显示小时和分钟,则可以使用图像。但我认为几秒钟改变图像将不是实际的解决方案。