Skip to content Skip to sidebar Skip to footer

Rotate A Layout Like A Pendulum

Can I move a inflated layout or dialog or(another way) etc like a PENDULUM. Inflated layout contain some image view and text view . Is it possible through animation or not thanks i

Solution 1:

You can use a RotateAnimation and assign it to your parent view.

However, to get a swing effect (like a pendulum) you need to provide proper values for pivot and degrees.

<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" />

In your case you need a layer-list drawable to combine an image with a text. See this. http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList

However, you can use a Drawable and not a View in LayerList. So the thing is you cannot use a View but will have to create a custom Drawable.

Post a Comment for "Rotate A Layout Like A Pendulum"