I would like to create a custom rectangular progress bar with white background colour. There is a text centered in the progress bar which defines the height of the progressbar. There is another view with black background colour which grows in width from the left side depending on the progress. I have this but it doesn't work:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:background="#FFFFFF" // this defines background colour
android:weightSum="1.0">
<LinearLayout // this should be aligned to the left side
android:layout_width="0dp"
android:layout_weight="0.25" // this should define percentage width
android:layout_height="fill_parent" // it should have height same as the TextView
android:background="#FF000000" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="40dp"
android:gravity="center" // it should be displayed in the center of the progress bar
android:text="some text"/>
EDIT: OK, I have this:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#FFFFFFFF">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:gravity="left"
android:weightSum="1.0">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="0.25"
android:layout_height="fill_parent"
android:background="#FF000000" />
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#777777"
android:textSize="40dp"
android:gravity="center"
android:text="@{data.remainingTime}"/>
</RelativeLayout>
The only problem is: how to tell LinearLayout to be exactly as high as the TextView?