RelativeLayout.LayoutParams paramsStrength = newRelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);</p>
leftmargin = ((MySeekBar)mProgress).getSeekBarThumb().getBounds()
.centerX()
– tvWeight.getWidth() / 2+10;
if (leftmargin < 0)
leftmargin = 0;
paramsStrength.leftMargin = leftmargin;
tvWeight.setLayoutParams(paramsStrength);
tvWeight.setText(stringForTime(mPlayer.getCurrentPosition()));
//继承重写seekbar代码以获取thumb的对象
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.SeekBar;
public class MySeekBar extends SeekBar {
DrawablemThumb;
publicMySeekBar(Context context) {
super(context);
}
publicMySeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
publicMySeekBar(Context context, AttributeSet attrs, int defStyle){
super(context, attrs, defStyle);
}
@Override
public voidsetThumb(Drawable thumb) {
super.setThumb(thumb);
mThumb =thumb;
}
publicDrawable getSeekBarThumb() {
returnmThumb;
}
}