如何从其中心位置旋转imageview,其他布局图像也动画

时间:2013-12-17 05:21:02

标签: android android-layout

我想从其中心位置旋转imageView1,其他图像也会移动 我的布局是

 <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" />
当imageView1动画时,

imageView3为android:layout_alignRight="@+id/imageView1"android:layout_below="@+id/imageView1",为什么我的imageView2imageView3不会关注这些图片

我像这样动画

RotateAnimation anim = new RotateAnimation(0, 15, 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);
            setuplayout();

enter image description here

1 个答案:

答案 0 :(得分:0)

就动画而言,尝试这个..

@Override
        public void show() {
            super.show();
            RotateAnimation anim = new RotateAnimation(0.0f, 360.0f , Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
            anim.setInterpolator(new LinearInterpolator());
            anim.setRepeatCount(Animation.INFINITE);
            anim.setDuration(3000);
            iv.setAnimation(anim);
            iv.startAnimation(anim);
        }

当你需要使用这个动画时,试试这样的事情......

your_inatance_image.show();