Fullscreen ProgressBar on WearOS

Viewed 216

I'm trying to get a ProgressBar that goes around the edge of the entire screen on a WearOS watch, like this:

enter image description here

I thought having a layout like this would work but this just makes a big ProgressBar in the center of the screen:

<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
            
    <ProgressBar
        android:id="@+id/progress_bar"
        style="@android:style/Widget.Material.ProgressBar.Large"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    
</androidx.constraintlayout.widget.ConstraintLayout>

Update

I found you can use a layer-list to change the size of the ProgressBar:

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/progress">
 
          <shape
                android:radius="18dp"
                android:shape="ring"
                android:thickness="2dp"
                android:useLevel="true">
            </shape>
    </item>
</layer-list>

If you could programmatically set android:radius to the size of the screen, it might work. Something like this:

GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setInnerRadius(18);
((ProgressBar)findViewById(R.id.progress_bar)).setProgressDrawable(gradientDrawable);
0 Answers
Related