发现Seekbar背景图片没有按当初设计的那样铺满背景。
网上很少相关资料,自己测试发现ProgressBar没有这个问题,并且与属性maxHeight有关系。maxHeight>=thunb的高度时正常。
查看源码发现Seekbar继承的类AbsSeekBar类下面有个函数updateThumbPos
private void updateThumbPos(int w, int h) {
Drawable d = getCurrentDrawable();
Drawable thumb = mThumb;
int thumbHeight = thumb == null ? 0 : thumb.getIntrinsicHeight();
// The max height does not incorporate padding, whereas the height
// parameter does
int trackHeight = Math.min(mMaxHeight, h - mPaddingTop - mPaddingBottom);
int max = getMax();
float scale = max > 0 ? (float) getProgress() / (float) max : 0;
if (thumbHeight > trackHeight) {
if (thumb != null) {
setThumbPos(w, thumb, scale, 0);
}
int gapForCenteringTrack = (thumbHeight - trackHeight) / 2;