Android Custom Horizontal Bitmap Indicator

I am using a custom progress bar that can be used for a horizontal progress bar in an Android app. It is a two-tier. The first layer is a diagonal striped png image with tileMode="repeat" . The second layer adds shadow over the stripes. This is what progress_bar_horizontal.xml drawable looks like:

  <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/progress"> <clip> <layer-list> <item> <bitmap android:src="@drawable/diagonal_stripes_0" android:tileMode="repeat" /> </item> <item> <nine-patch android:src="@drawable/inset_shadow" /> </item> </layer-list> </clip> </item> </layer-list> 

This drawable is used in the theme for restyling performance control:

  <style name="Theme.Custom" parent="android:Theme.Light"> <item name="android:progressBarStyleHorizontal">@style/Widget.ProgressBar.Horizontal.Custom</item> </style> <style name="Widget.ProgressBar.Horizontal.Custom" parent="android:Widget.ProgressBar.Horizontal"> <item name="android:background">@drawable/bg_inset_gray</item> <item name="android:progressDrawable">@drawable/progress_bar_horizontal</item> <item name="android:indeterminateDrawable">@drawable/progress_bar_indeterminate_horizontal</item> </style> 

The idea is to make a diagonally striped progress bar that does not work, but grows as you progress through the operation. This is why <clip> .

It works great in most cases. However, from time to time (without any chance of intentionally reproducing it), it begins to stretch a single plate with the possibility of drawing, and not cut it off accordingly.

The application was developed using android:minSdkVersion="7" and runs on HTC Desire with Android 2.2.

Any help would be appreciated.

+4
source share

All Articles