旋转就像一个钟摆布局 [英] Rotate a layout like a PENDULUM

查看:183
本文介绍了旋转就像一个钟摆布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将一个充气的布局或对话或(另一种方法)等就像一个钟摆。充气布局包含一些图像视图和文本视图。是否有可能通过动画与否

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

在此先感谢

推荐答案

您可以使用的 RotateAnimation ,然后将其分配给你的父视图。

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

在你的情况,你需要一个图层列表绘制到图像结合的文本。看到这一点。 的http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList

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

不过,您可以使用一个可绘制对象,而不是在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.

这篇关于旋转就像一个钟摆布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆