From 3b2272cb2372933f22d769be4c885a176e4ef542 Mon Sep 17 00:00:00 2001 From: Marcus Danielsson Date: Wed, 17 Apr 2013 13:57:59 +0200 Subject: [PATCH] Round off when calculate next step in Seekbar When the positions for the new step is calculated in a Seekbar, a rounding error can appear. This is fixed by round off before casting. Change-Id: Ie2cf201ef670ccc2297e9bc4c7f415a826e44a41 --- core/java/android/widget/AbsSeekBar.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java index 7674837e3a129..fe2fc965848bc 100644 --- a/core/java/android/widget/AbsSeekBar.java +++ b/core/java/android/widget/AbsSeekBar.java @@ -292,7 +292,7 @@ public abstract class AbsSeekBar extends ProgressBar { // The extra space for the thumb to move on the track available += mThumbOffset * 2; - int thumbPos = (int) (scale * available); + int thumbPos = (int) (scale * available + 0.5f); int topBound, bottomBound; if (gap == Integer.MIN_VALUE) {