Android ProgressBar UI custom layout

The solution (feels weird answering your own):
First, one problem was that progress drawable had a different size than background (stupid me!). Also, for progress drawable a clip xml was needed. Something like progressbar_progress_clip.xml:

<?xml version="1.0" encoding="utf-8"?>
<clip
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="https://stackoverflow.com/questions/9921621/@drawable/progressbar_progressing"
    android:clipOrientation="horizontal"
    android:gravity="left"/>

Then, add the progress bar and two images in a relative layout, so that the images can be drawn after the status bar. Something like this:

<RelativeLayout
                android:id="@+id/relativeLayout1"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_marginLeft="10dip"
                android:layout_marginRight="10dip"
                android:layout_weight="94" >

                <ProgressBar
                    android:id="@+id/pBarOverallStatus"
                    style="?android:attr/progressBarStyleHorizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_marginBottom="2dp"
                    android:layout_marginTop="2dp"
                    android:indeterminateOnly="false"
                    android:max="100"
                    android:progressDrawable="@drawable/progressbar_progress_clip" >
                </ProgressBar>

                <ImageView
                    android:id="@+id/ringLeft"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_alignParentLeft="true"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="7dp"
                    android:contentDescription="@string/status_bar_ring"
                    android:src="https://stackoverflow.com/questions/9921621/@drawable/status_bar_ring" />

                <ImageView
                    android:id="@+id/ringRight"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="7dp"
                    android:contentDescription="@string/status_bar_ring"
                    android:src="https://stackoverflow.com/questions/9921621/@drawable/status_bar_ring" />
            </RelativeLayout>

Thanks, guys!

Leave a Comment