【问题标题】:join up two or more ImageViews连接两个或多个 ImageView
【发布时间】:2015-06-23 12:41:07
【问题描述】:

我的布局中有 4 个 Framelayouts 和 2 个 ImageView(一个可见,一个不可见)。在单击第一个 ImageView 后,在 Framelayout 中,它会旋转到第二个 ImageView。就像在这个例子中一样(http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html)。它工作正常,但是有没有组合两个或多个 ImageView 的选项?因此,如果我单击第一张图片(android:id="@+id/HotView1"),我的 android:id="@+id/HotView2" 和 android:id="@+id/WarmView2" 一起旋转为一个图像?

当然,我可以依次旋转每个视图,但由于旋转时的相机角度,这看起来不太好。有什么简单快捷的解决方案吗?

[...]
    <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>
[...]

【问题讨论】:

  • 在一个线性或相对布局中添加两个图像,为整个布局提供动画。
  • 但这取决于...有时我想组合图像有时不。我的旋转方法如下所示:private void applyRotation(float start, float end, ImageView image1,ImageView image2)。所以我需要一个 ImageView 来旋转

标签: java android imageview


【解决方案1】:

大家好,首先给你想要动画的 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);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-02
    • 1970-01-01
    相关资源
    最近更新 更多