diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-08-20 12:22:08 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-08-20 12:22:08 -0700 |
commit | 05b11cd7cce4c6a85438899da57210394d1f6ef8 (patch) | |
tree | a4c3cdc932d71bcbc2e69ffe1feea5b1cfb611c9 /core/java/android | |
parent | ba377496347e29aeca1540d51b150eebc2634ad6 (diff) | |
parent | 8d28c3b3bdab63fab132b81e38d54bc4c132ea8a (diff) | |
download | frameworks_base-05b11cd7cce4c6a85438899da57210394d1f6ef8.zip frameworks_base-05b11cd7cce4c6a85438899da57210394d1f6ef8.tar.gz frameworks_base-05b11cd7cce4c6a85438899da57210394d1f6ef8.tar.bz2 |
Merge change 22082 into eclair
* changes:
Address b/2064664 by setting mThumbOffset to half the width of the thumb by default.
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/widget/AbsSeekBar.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java index f92eb99..2a0e5e5 100644 --- a/core/java/android/widget/AbsSeekBar.java +++ b/core/java/android/widget/AbsSeekBar.java @@ -64,10 +64,10 @@ public abstract class AbsSeekBar extends ProgressBar { TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.SeekBar, defStyle, 0); Drawable thumb = a.getDrawable(com.android.internal.R.styleable.SeekBar_thumb); - setThumb(thumb); + setThumb(thumb); // will guess mThumbOffset if thumb != null... + // ...but allow layout to override this int thumbOffset = - a.getDimensionPixelOffset(com.android.internal.R.styleable.SeekBar_thumbOffset, 0); - setThumbOffset(thumbOffset); + a.getDimensionPixelOffset(com.android.internal.R.styleable.SeekBar_thumbOffset, getThumbOffset()); a.recycle(); a = context.obtainStyledAttributes(attrs, @@ -77,13 +77,21 @@ public abstract class AbsSeekBar extends ProgressBar { } /** - * Sets the thumb that will be drawn at the end of the progress meter within the SeekBar + * Sets the thumb that will be drawn at the end of the progress meter within the SeekBar. + * <p> + * If the thumb is a valid drawable (i.e. not null), half its width will be + * used as the new thumb offset (@see #setThumbOffset(int)). * * @param thumb Drawable representing the thumb */ public void setThumb(Drawable thumb) { if (thumb != null) { thumb.setCallback(this); + + // Assuming the thumb drawable is symmetric, set the thumb offset + // such that the thumb will hang halfway off either edge of the + // progress bar. + mThumbOffset = (int)thumb.getIntrinsicWidth() / 2; } mThumb = thumb; invalidate(); |