像钟摆一样旋转布局



我可以移动一个膨胀的布局或对话框或(另一种方式)像钟摆。膨胀布局包含一些图像视图和文本视图。是否可以通过动画

thanks in advance

你可以使用RotateAnimation并将它分配给你的父视图。

然而,要获得一个摆动效果(如钟摆),您需要为枢轴和度提供适当的值。

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="50%" android:pivotY="50%" android:fromDegrees="-135"
android:toDegrees="-45" android:drawable="@drawable/imagefile_to_rotate"
android:repeatCount="infinite" />

在您的情况下,您需要一个可绘制的图层列表来组合图像和文本。看到这个。http://developer.android.com/guide/topics/resources/drawable-resource.html LayerList

然而,你可以在LayerList中使用Drawable而不是View。所以问题是你不能使用视图而必须创建一个自定义Drawable

最新更新