我需要一个看起来像旋转进度圈的可绘制对象。我想在 GridView 内的 ImageView 等中使用该可绘制对象。
因此,根据其他帖子,我从文件夹 \sdk\platforms\android-xx\data\res\drawable 中获取了 Progress_medium_holo.xml ,如下所示。我还复制了该可绘制对象使用的 PNG 文件。
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:drawable="@drawable/spinner_48_outer_holo"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="0"
android:toDegrees="1080" />
</item>
<item>
<rotate
android:drawable="@drawable/spinner_48_inner_holo"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="720"
android:toDegrees="0" />
</item>
</layer-list>
在我的布局中,我使用了这个 ImageView ,它使用了进度绘制。
<ImageView
android:id="@+id/element_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:src="@drawable/progress_medium_holo" />
但结果是一个静态的循环进步。有没有一种方法可以通过 XML 定义来动画化该动画而不使用任何代码?
有一个View
named ProgressBar
这正是你想要的。
只需用这个代替你的ImageView
:
<ProgressBar
android:id="@+id/element_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingBottom="5dp"
android:paddingTop="5dp" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)