开发者

Android SeekBar Jiggles

I haven't seen this issue covered on SO so here it goes. I have a seekbar that prevents seeking beyond the secondary progress(in this case, music buffering). Let's say the song is 5 minutes long, 4 minutes have been buffered, and it is playing at the one minute mark. When I go to drag the thumb, it drags and drops fine. The issue is that when I stop dragging(without releasing) and then drag again, the thumb is rapidly jumping from the currently playing position(1 minute) to the position I am dragging the thumb. When I release, it's fine, it's only an issue with dragging the thumb. Here is my seekbar listener....

private SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {

    public void onProgressChanged(SeekBar seekBar, int progress,
            boolean fromUser) {

        int secondaryPosition = seekBar.getSecondaryProgress();
        if (progress > secondaryPosition) {
            seekBar.setProgress(secondaryPositio开发者_开发问答n-1);
        }
    }

    public void onStartTrackingTouch(SeekBar seekBar) {

    }

    public void onStopTrackingTouch(SeekBar seekBar) {
        seekMediaPlayerToSeekBarTouch(seekBar);
    }

};


I'm guessing you have a Handler or a Thread to update the SeekBar? I would recommend setting up a basic check to see if the user is handling the SeekBar so it won't keep trying to redraw the thumb for the SeekBar while it's being handled. Just set a boolean, such as mSeekbarTracking to true in the onStartTrackingTouch() method, then in the SeekBar updater, make it check that mSeekbarTracking is false before it tries to update it.

I don't know if that will solve all of your problems though. Maybe you could try that and see how it affects your issue. It will probably help us help you if you post the code that you're using to update the SeekBar.

Cheers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜