我想旋转其他图片也相对于动画图像移动的图像
XML是:
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="86dp"
android:src="@drawable/top_pati" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageView1"
android:layout_below="@+id/imageView1"
android:src="@drawable/top_pativertical" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/imageView1"
android:layout_below="@+id/imageView1"
android:src="@drawable/top_pativertical" />
Java代码就是这样:
imageView= (ImageView) findViewById(R.id.imageView1);
imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
RotateAnimation anim = new RotateAnimation(0,45 , Animation.RELATIVE_TO_SELF,
0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setInterpolator(new LinearInterpolator());
anim.setDuration(500);
anim.setFillEnabled(true);
anim.setFillAfter(true);
imageView.startAnimation(anim);
}
});
我想使用对象动画,这里我使用的旋转动画不会移动imageview的实际位置 我该如何使用对象动画..
答案 0 :(得分:1)
final ImageView mytrain = (ImageView) findViewById(R.id.train);
final Animation traintween = AnimationUtils.loadAnimation(this,R.anim.treinanimation);
final Animation trainfade = AnimationUtils.loadAnimation(this,R.anim.trainfade);
AnimationSet s = new AnimationSet(false);//false mean dont share interpolators
s.addAnimation(traintween);
s.addAnimation(trainfad);
mytrain.startAnimation(s);
此示例设置为在一个图像上应用多个动画..
答案 1 :(得分:0)
创建此xml文件并在xml
中的imageview中设置此文件<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/loading"
android:pivotX="50%"
android:pivotY="50%" />
答案 2 :(得分:0)
RotateAnimation anim = new RotateAnimation(0f, 350f, 15f, 15f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(700);
// Start animating the image
final ImageView splash = (ImageView) findViewById(R.id.splash);
splash.startAnimation(anim);
// Later.. stop the animation
splash.setAnimation(null);