伙计我正在扩展进度条,我正在更改进度条的高度并设置填充。一切都很好,除了BOTTOM填充。问题是当我尝试使用代码时它只显示顶部填充,而没有底部填充。
@Override
protected synchronized void onMeasure(int widthMeasureSpec,
int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
setMeasuredDimension(getMeasuredWidth(), mMaxThumbDrawable.getHeight());
if(getWidth() > 0)
mPixels = getWidth() / mRange;
paddintBottom = (int)(0.8f * getHeight());
paddintTop = (int)(0.4f * getHeight());
setPadding(0, paddintTop, 0, paddintBottom);
}
XML如下
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="true"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<com.example.customseekbarwidget.DoubleSlider
android:id="@+id/doubleSlider1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:progressDrawable="@drawable/progress_bar_bg" />
</LinearLayout>
问题的有趣部分是如果我指定像44这样的常量值代替paddintBottom
setPadding(0, paddintTop, 0, 44);
它突然开始工作,但我无法保持价值不变。任何人都对此有所了解。