Search code examples
javaandroidprogress-barandroid-progressbar

Circular Progressbar showing square corners


I have this issue, My progress drawable that I use for a progressbar in activity, works perfectly normal. But once I use the same drawable resource to display progressbar in my recyclerview these corners around progressbar show up.

Here is my progressbar view code:

    <ProgressBar
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_alignParentEnd="true"
        android:layout_marginRight="12dp"
        android:layout_marginTop="8dp"
        android:indeterminate="false"
        style="@style/Widget.AppCompat.ProgressBar.Horizontal"
        android:progressDrawable="@drawable/newshit"
        android:layout_alignParentRight="true"
        android:id="@+id/ProgressBarMain"/>

And here is the custom progressbar drawable.

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
  android:fromDegrees="270"
  android:toDegrees="270">
  <shape
      android:innerRadiusRatio="2.5"
      android:shape="ring"
      android:thickness="15dp"
      android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->

      <gradient
          android:angle="0"
          android:endColor="@color/green"
          android:centerColor="#f6e41a"
          android:startColor="@android:color/holo_red_light"
          android:type="sweep"
          android:useLevel="false" />

       </shape>
       </rotate>

Custom Progressbar (Determinate) showing weird corners in recyclerview


Solution

  • Check this sample.

    <rotate xmlns:android="http://schemas.android.com/apk/res/android"
      android:fromDegrees="270"
      android:toDegrees="270">
      <shape
          android:innerRadiusRatio="3"
          android:shape="ring"
          android:thickness="8"
          android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->
    
          <gradient
              android:angle="0"
              android:endColor="@color/green"
              android:centerColor="#f6e41a"
              android:startColor="@android:color/holo_red_light"
              android:type="sweep"
              android:useLevel="false" />
    
      </shape>
    </rotate>