显示方角的圆形进度条

时间:2021-03-18 06:51:48

标签: java android progress-bar android-progressbar

我有这个问题,我在活动中用于进度条的进度可绘制完全正常。但是一旦我使用相同的可绘制资源在我的回收站视图中显示进度条,进度条周围的这些角落就会出现。

这是我的进度条视图代码:

    <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"/>

这是可绘制的自定义进度条。

<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

1 个答案:

答案 0 :(得分:1)

检查此示例。

<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>