Search code examples
androidxmlwear-os

How to put progress bar around the edge of the screen in Wear OS


guys I am trying to make my progress bar around the edge of the screen but it's not happening even tho i put both width and height to match_parent still it's sitting in the centre not on the edges.

Here is my progress bar code

<ProgressBar
        android:id="@+id/pgMeasurement"
        style="@android:style/Widget.DeviceDefault.Light.ProgressBar.Large"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="visible"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

here are the end results


Solution

  • The xml code I use:

    <ProgressBar
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_centerInParent="true"
            android:indeterminate="false"
            android:max="100"
            android:progress="100"
            android:progressDrawable="@drawable/circular_progress_bar"
    

    The drawable file:

    <?xml version="1.0" encoding="utf-8"?>
    <rotate xmlns:android="http://schemas.android.com/apk/res/android"
        android:fromDegrees="270"
        android:toDegrees="270">
    
        <shape
            android:shape="ring"
            android:innerRadiusRatio="2.02"
            android:thickness="2px"
            android:useLevel="true">
    
            <gradient
                android:angle="0"
                android:endColor="#FFFFFF"
                android:startColor="#FFFFFF"
                android:type="sweep"
                android:useLevel="false" />
        </shape>
    </rotate>