There's number to solutions to the problem:
- Use 9patch image for backgorund (which is basically should be used as background for seekbar). Like the following:
(name should be unselect_patch.9.png
) and slightly modify custom_seekbar.xml
to look like the following:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@android:id/background"
android:drawable="@drawable/unselect_patch"/>
<item android:id="@android:id/secondaryProgress">
<clip>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/select"
android:tileMode="disabled" />
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/select"
android:tileMode="disabled" />
</clip>
</item>
</layer-list>
- Just provide exact size of the image in layout (e.g.
layout_width="@dimen/select_image_width"
);
To support all resolutions - provide images for different resolutions, as described in Supporting Multiple Screens. The same images will not work fine for all resolutions and here's better just follow best practices described in detail at the link above.