3

我做了什么..

<item>
    <rotate
        android:fromDegrees="40"
        android:toDegrees="20"
        android:pivotX="25%"
        android:pivotY="50%" >
        <shape
            android:shape="line"
            android:top="1dip" >
            <stroke
                android:width="1dip"
                android:color="#FF0000" />
        </shape>
    </rotate>
</item>

它旋转但不弯曲。需要弯曲成弧形

任何想法?

4

1 回答 1

3

您可以绘制一个ring形状,根据您的喜好旋转它,并将其与ProgressBar设定progressDrawable的进度一起使用。

可绘制的.xml

<?xml version="1.0" encoding="utf-8"?>
<rotate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="150"
    android:toDegrees="150">

    <shape
        android:shape="ring"
        android:thickness="10dp"
        android:innerRadius="20dp"
        android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->

        <solid android:color="@color/colorPrimary"/>

    </shape>
</rotate>

布局.xml

<ProgressBar
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="120dp"
    android:layout_height="120dp"
    android:progressDrawable="@drawable/widget_arc"
    android:indeterminate="false"
    android:max="100"
    android:progress="67"
    />

您可以动态设置进度,也可以轻松设置动画

*使用维度 res 值

于 2017-04-20T08:50:53.610 回答