chiranjib
chiranjib

Reputation: 5308

Display duration for Timer in the following format

I have developed a Timer component. Currently the time is being display as follows:

enter image description here

I want to display the time in the following manner, better to say in that specific digital format.

enter image description here

What changes should I make in the layout XML, or what should be my approach?

Upvotes: 1

Views: 711

Answers (3)

N-JOY
N-JOY

Reputation: 7635

I am not sure actually but I think you will have to use images for that. This is possible using images if you are just showing hrs and min. But I think for seconds changing images will not be a practical solution.

Upvotes: 0

amiekuser
amiekuser

Reputation: 1630

The format you gave is not visible, though you can do something like this:

SimpleDateFormat stf = new SimpleDateFormat("hh:mm a");
System.out.println(" The time is " + stf.format(cal.getTime()));

This will print in a twelve hr format mentioning AM/PM.

SimpleDateFormat stf = new SimpleDateFormat("HH:mm:ss");

This will make it in 24 hrs format.

Upvotes: 0

thoredge
thoredge

Reputation: 12591

I don't think there is a font for what you want in Android. I would've just drawn this directly on Canvas. Alternatively you can create one Canvas-based component per digit.

I think this blog/article about Android vector drawing on Canvas could be useful to you http://www.simonhildebrandt.com/home/tipofthedayvectorrenderinginandroid

Upvotes: 1

Related Questions