材质设计进度条看起来很酷,但是我不能在Lollipop之前的设备上使用它。有人知道有什么办法吗?
我迟到了,这是您的方法。
在您的drawable文件夹中执行以下操作,创建一个progress_animator
包含以下内容的文件:
<?xml version="1.0" encoding="utf-8"?><!--<layer-list>-->
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="1080">
<layer-list>
<item>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="-90"
android:toDegrees="-90">
<shape
android:innerRadiusRatio="3.0"
android:shape="ring"
android:thickness="2.5dp"
android:useLevel="true">
<gradient
android:angle="0"
android:endColor="@color/colorAccent"
android:startColor="@color/colorAccent"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
</item>
</layer-list>
</rotate>
现在,在您的布局中,您将必须在ProgressBar中添加一个不确定的进度可绘制对象:
<ProgressBar
android:id="@+id/progressBarPreview"
style="@style/Widget.AppCompat.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:indeterminateDrawable="@drawable/progress_animator"
/>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句