Android - How to mark timestamps on a SeekBar

963 views Asked by At

I will be working on an app that records button presses, where I can play back that session on a SeekBar. Each event will be timestamped from the value of a Chronometer. When playing back, on each of those recorded events I will play a sound. That part shouldn't be a problem.

Now, what I would like to figure out is how I can mark the timestamps on the SeekBar by drawing red bars at the positions where each event occurred. I would like the red bars to be drawn prior to playback.

Since I haven't started this app yet, I don't have any code at this time.

2

There are 2 answers

0
Cookster On BEST ANSWER

If I were to this, I would use the following procedures:

  1. Grab a handle to the seekbar view in my java code and save the width.
  2. The width represents your timescale starting at 0 to whenever the user stops acting on the view. Lets call that stop value T (seconds).
  3. After the recording completes, divide the width into seconds based on T.
  4. Each time stamp will map to an x-coordinate based on #3. Draw a red vertical line centered over that seekbar view at x. If you draw it on top, it might mess up seekbar interaction.

I know this isn't code but hopefully it will give you a good idea on how to solve this problem.

0
Azim Ansari On

You can't mark anything on seek bar. So don't use seek bar. Just use a simple Pixels to draw as a line with width of match_parent and height of 2dp. Put a small circular image as seek bar over there. Then mark pixels wherever you want marking.

Look at the concept

...................O............................................................

This is your seekbar. Mark particular point for you dynamically.