朋友们,帮帮我。我在项目中有一个定制的SeekBar。它没有正确显示。http://take.ms/NgHW9

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@mipmap/ballance_bg"
android:gravity="center"
android:padding="2dp">
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="false"
android:focusable="false"
android:max="1"
android:maxHeight="5dp"
android:minHeight="1dp"
android:paddingLeft="1dp"
android:paddingRight="1dp"
android:progress="0"
android:progressDrawable="@drawable/seekbar_progress"
android:saveEnabled="true"
android:thumb="@mipmap/point_icon"
android:thumbOffset="0dp" />
</LinearLayout>有自定义的可绘制资源- seekbar_progress
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/like_line_2"
android:dither="true"/>
</item>
<item
android:id="@android:id/progress"
android:drawable="@drawable/red_seekbar_progress" /></layer-list>like_line_2为9.补丁图像
有自定义的可绘制资源- red_seekbar_progress
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<clip>
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/dislike_line_2"
android:dither="true"
/>
</clip>
</item></layer-list>dislike_line_2为9.补丁图像
此代码填充SeekBar。
seek_1 = (SeekBar) view.findViewById(R.id.seekBar);
seek_1.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return true;
}
});
int sum = Integer.parseInt(products.get(0).getPositive_count()) + Integer.parseInt(products.get(0).getNegative_count());
seek_1.setMax(sum);
seek_1.setProgress(Integer.parseInt(products.get(0).getNegative_count()));此错误出现在不同的SeekBars中。
发布于 2016-06-09 08:26:02
我自己找到了解决方案。那就是错误的地方。
<item
android:id="@android:id/progress"
android:drawable="@drawable/red_seekbar_progress" /> 尽量不要在另一个XML项中使用XML。
正确版本:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"><item android:id="@android:id/background">
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/like_line_2"
android:dither="true"/>
</item>
<item
android:id="@android:id/progress">
<clip>
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/dislike_line_2"
android:dither="true"/>
</clip>
</item>
</layer-list>https://stackoverflow.com/questions/37438809
复制相似问题