我创建了一个自定义搜索栏,它适用于4.1设备,但在4.2和4.3设备上它不显示我的背景,它只是留空。
这就是我的所作所为:
mySeekbar.setProgressDrawable(getResources().getDrawable(R.drawable.seekbar_progress));
mySeekbar.setBackgroundDrawable(getResources().getDrawable(R.drawable.slider_shape));
seekbar_progress.xml:
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@android:id/background">
<bitmap
android:src="@drawable/slider_background_part"
android:tileMode="repeat">
</bitmap>
</item>
<item
android:id="@android:id/progress">
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<clip>
<color
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/my_slider_color"/>
</clip>
</item>
<item>
<clip >
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/slider_foreground_part"
android:tileMode="repeat"/>
</clip>
</item>
</layer-list>
</item>
在这个文件中,我正在重复进行背景和背景的图像,为了进步,我给它一定的颜色。 然后我仍然需要为我的背景设置一个形状。如果我不这样做,背景就会一直是空白的。
slider_shape.xml:
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="0dp"/>
</shape>
有人可以帮助我吗?