android中的动画轮子效果
有没有办法像这样在Android的按钮后面创建一个光线动画 它应该在硬币后面旋转 光线应该在父布局的矩形内旋转。 有什么简单的方法吗 我的代码:android中的动画轮子效果,android,animation,Android,Animation,有没有办法像这样在Android的按钮后面创建一个光线动画 它应该在硬币后面旋转 光线应该在父布局的矩形内旋转。 有什么简单的方法吗 我的代码: final Animation animRotate = AnimationUtils.loadAnimation(context,R.anim.image_rotate); ImageView rl2=(ImageView) view.findViewById(R.id.ss); rl2.startAnimation(animRotate);
final Animation animRotate = AnimationUtils.loadAnimation(context,R.anim.image_rotate);
ImageView rl2=(ImageView) view.findViewById(R.id.ss);
rl2.startAnimation(animRotate);
and xml file:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:duration="10000"
android:repeatMode="restart"
android:repeatCount="-1"
android:pivotX="50%"
android:pivotY="50%">
</rotate>
</set>
final Animation animorotate=AnimationUtils.loadAnimation(上下文,R.anim.image\u rotate);
ImageView rl2=(ImageView)view.findViewById(R.id.ss);
rl2.开始动画(动画旋转);
和xml文件:
您可以使用objectAnimator来实现这一点
<objectAnimator
android:duration="3000"
android:propertyName="rotation"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueTo="360"
android:valueType="floatType" />
还有一件事,加速\减速\插值器使动画在开始时加速,在结束时减速。相对于轴点旋转背景图像,轴点将是图像的中心点
ImageView img = (ImageView) view.findViewById(R.id.ss);
RotateAnimation rotateAnimation = new RotateAnimation(0f,360f, Animation.RELATIVE_TO_SELF,0.5f, Animation.RELATIVE_TO_SELF,0.5f);
rotateAnimation.setInterpolator(new LinearInterpolator());
rotateAnimation.setDuration(1000);
rotateAnimation.setRepeatCount(Animation.INFINITE);
img.startAnimation(rotateAnimation);
你能旋转它吗?是的,我能旋转图像。但我的问题是,当它旋转它时,它的视图超出了这个布局。我的问题是切断旋转图像,例如:我在relativelayout视图中有一个imageview,希望旋转它,使其居中并切断父布局的边框。在XML文件中的imageview及其父视图上,尝试设置android:clipChildren=“false”和android:clipToPadding=“false”感谢您的回复。但它的显示与以前一样。赋予这些属性后没有任何更改。感谢您的回复。旋转时,其视图将脱离此布局。我的问题是旋转图像被切断,例如:我在relativelayout视图中有一个imageview,我想旋转它,使其居中并切断父布局的边界。我在上面添加了一个链接。我们可以用另一种方式实现这样的效果吗。在relativelayout中不使用imageview。我的意思是不旋转图像。我已经将其放在上面。请检查它。在背景(即射线图像)并检查一次。并请发布包含这些图像视图的布局内容。