2015-06-23 26 views
0

我有4个Framelayouts与2个ImageViews(一个可见,一个不可见)在我的布局。在第一个ImageView上点击后,在Framelayout中,旋转到第二个ImageView。像在这个例子中一样(http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html)。它工作正常,但有没有选择组合两个或更多ImageViews?所以,如果我点击第一个图像(android:id =“@ + id/HotView1”),我的android:id =“@ + id/HotView2”和android:id =“@ + id/WarmView2”旋转togehter为一个图像?加入两个或多个ImageViews

当然,我可以顺序旋转每个视图,但由于相机角度的旋转,这看起来不太好。是否有任何简单快捷的解决方案?

[...] 
    <FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="center" > 

     <ImageView 
      android:id="@+id/HotView1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/hot_notactiv" /> 

     <ImageView 
      android:id="@+id/HotView2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/hot_activ" /> 
    </FrameLayout> 

    <FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" > 

     <ImageView 
      android:id="@+id/WarmView1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/warm_notactiv" /> 

     <ImageView 
      android:id="@+id/WarmView2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/warm_activ" /> 
    </FrameLayout> 
[...] 
+0

添加两一个线性或相对布局中的图像为整个布局提供动画。 – pcj

+0

但它,但它取决于...有时我想结合图像有时不。我的旋转方法如下所示:private void applyRotation(float start,float end,ImageView image1,ImageView image2)。所以我需要一个ImageView进行旋转 – h0ppel

回答

0

嗨,首先给所有你想要动画的LinearLayout和ImageView提供id。所以你可以参考他们。

然后定义一个函数,将动画像传递的观点:

public void myAnimation(View viewToAnimate) { 
// Your code for animating which will be comman 
} 

现在同时获得的LinearLayout和ImageView的的参考,检查条件,其浏览动画,如:

if(wantToAnimateLinearLayout == true) { 
    myAnimation(linearLayoutReference); 
} else { 
    myAnimation(imageViewReference); 
}