Android-Round ProgressBar在错误的位置启动

Android-Round ProgressBar在错误的位置启动,android,progress-bar,Android,Progress Bar,我正在尝试向我的应用程序添加一个圆形进度条,我希望从圆圈的顶部开始,并在顶部结束。然而,我尝试的任何角度等都不会改变外观。我对安卓相当陌生,所以对我放松点。这是我的密码: <ProgressBar android:id="@+id/progressBar" android:layout_width="300dp" android:layout_height="300dp" android:indeterminate="false" android:l

我正在尝试向我的应用程序添加一个圆形进度条,我希望从圆圈的顶部开始,并在顶部结束。然而,我尝试的任何角度等都不会改变外观。我对安卓相当陌生,所以对我放松点。这是我的密码:

<ProgressBar
    android:id="@+id/progressBar"
    android:layout_width="300dp"
    android:layout_height="300dp"
    android:indeterminate="false"
    android:layout_centerInParent="true"
    android:progressDrawable="@drawable/circular_progress_bar"
    android:background="@drawable/circle_shape"
    style="?android:attr/progressBarStyleHorizontal"
    android:max="100"
    android:progress="30" />

圆圈形状.xml

<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadiusRatio="2.5"
android:thickness="6dp"
android:useLevel="false">

<solid android:color="#CCC" />

</shape>
<?xml version="1.0" encoding="utf-8"?>
<clip>
<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="6dp">
    <gradient
        android:angle="0"
        android:endColor="#38C0F4"
        android:startColor="#38C0F4"
        android:centerColor="#56ccb7"
        android:type="sweep"
        android:useLevel="false" />
</shape>
</rotate>
</clip>

circular\u progress\u bar.xml

<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadiusRatio="2.5"
android:thickness="6dp"
android:useLevel="false">

<solid android:color="#CCC" />

</shape>
<?xml version="1.0" encoding="utf-8"?>
<clip>
<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="6dp">
    <gradient
        android:angle="0"
        android:endColor="#38C0F4"
        android:startColor="#38C0F4"
        android:centerColor="#56ccb7"
        android:type="sweep"
        android:useLevel="false" />
</shape>
</rotate>
</clip>

以下是进度达到30%时的屏幕截图:

您需要编辑您的循环\u progress\u bar.xml

  • 去掉剪辑标签
  • 将[android:useLevel=“true”]添加到形状属性。(这是Android 5(21)的新功能)

    
    

  • 我认为您需要参考此链接,它将帮助您:。