Merge "Vertically center seek bar track and thumb when maxHeight is set"
This commit is contained in:
committed by
Android (Google) Code Review
commit
39df5fea22
@@ -403,23 +403,26 @@ public abstract class AbsSeekBar extends ProgressBar {
|
||||
}
|
||||
|
||||
private void updateThumbAndTrackPos(int w, int h) {
|
||||
final int paddedHeight = h - mPaddingTop - mPaddingBottom;
|
||||
final Drawable track = getCurrentDrawable();
|
||||
final Drawable thumb = mThumb;
|
||||
|
||||
// The max height does not incorporate padding, whereas the height
|
||||
// parameter does.
|
||||
final int trackHeight = Math.min(mMaxHeight, h - mPaddingTop - mPaddingBottom);
|
||||
final int trackHeight = Math.min(mMaxHeight, paddedHeight);
|
||||
final int thumbHeight = thumb == null ? 0 : thumb.getIntrinsicHeight();
|
||||
|
||||
// Apply offset to whichever item is taller.
|
||||
final int trackOffset;
|
||||
final int thumbOffset;
|
||||
if (thumbHeight > trackHeight) {
|
||||
trackOffset = (thumbHeight - trackHeight) / 2;
|
||||
thumbOffset = 0;
|
||||
final int offsetHeight = (paddedHeight - thumbHeight) / 2;
|
||||
trackOffset = offsetHeight + (thumbHeight - trackHeight) / 2;
|
||||
thumbOffset = offsetHeight + 0;
|
||||
} else {
|
||||
trackOffset = 0;
|
||||
thumbOffset = (trackHeight - thumbHeight) / 2;
|
||||
final int offsetHeight = (paddedHeight - trackHeight) / 2;
|
||||
trackOffset = offsetHeight + 0;
|
||||
thumbOffset = offsetHeight + (trackHeight - thumbHeight) / 2;
|
||||
}
|
||||
|
||||
if (track != null) {
|
||||
|
||||
@@ -1235,24 +1235,6 @@ public class ProgressBar extends View {
|
||||
}
|
||||
}
|
||||
|
||||
private void setDrawableTint(int id, ColorStateList tint, Mode tintMode, boolean fallback) {
|
||||
Drawable layer = null;
|
||||
|
||||
// We expect a layer drawable, so try to find the target ID.
|
||||
final Drawable d = mCurrentDrawable;
|
||||
if (d instanceof LayerDrawable) {
|
||||
layer = ((LayerDrawable) d).findDrawableByLayerId(id);
|
||||
}
|
||||
|
||||
if (fallback && layer == null) {
|
||||
layer = d;
|
||||
}
|
||||
|
||||
layer.mutate();
|
||||
layer.setTintList(tint);
|
||||
layer.setTintMode(tintMode);
|
||||
}
|
||||
|
||||
private synchronized void doRefreshProgress(int id, int progress, boolean fromUser,
|
||||
boolean callBackToApp) {
|
||||
float scale = mMax > 0 ? (float) progress / (float) mMax : 0;
|
||||
|
||||
Reference in New Issue
Block a user