我有一个可绘制的进度,在运行Android Lollipop的设备上无法正常工作。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="@color/colorTranslucentBlack"/>
</shape>
</item>
<item android:id="@android:id/progress">
<rotate
android:fromDegrees="270"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="270">
<shape
android:innerRadiusRatio="2.5"
android:shape="ring"
android:thicknessRatio="25.0">
<gradient
android:centerColor="@android:color/holo_red_dark"
android:endColor="@android:color/holo_red_dark"
android:startColor="@android:color/holo_red_dark"
android:type="sweep"/>
</shape>
</rotate>
</item>
<item android:id="@android:id/secondaryProgress">
<rotate
android:fromDegrees="270"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="270">
<shape
android:innerRadiusRatio="2.5"
android:shape="ring"
android:thicknessRatio="25.0">
<gradient
android:centerColor="@android:color/holo_red_dark"
android:endColor="@android:color/holo_red_dark"
android:startColor="@android:color/holo_red_dark"
android:type="sweep"/>
</shape>
</rotate>
</item>
</layer-list>
<ProgressBar
android:id="@+id/circle_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="70dp"
android:layout_height="70dp"
android:gravity="center"
android:progress="65"
android:indeterminate="false"
android:progressDrawable="@drawable/circle_percentage_drawable"
/>
渲染为65%的圈子显示在运行Android M,KitKat,Jellybean的设备上。但是,如果在Android Lollipop(API 21)上运行相同的代码,则圆圈显示为100%。
此处提供完整源代码:https://github.com/slashrootv200/CircleProgressPercentage
答案 0 :(得分:7)
在圆形进度条xml
中添加normal
android:useLevel=true"