In android Translate-Animation how to Translate vi

2019-06-07 05:42发布

问题:

Suppose i have one view say it as image1 like,

 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/image1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    <ImageView
        android:id="@+id/image2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/image3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    <ImageView
        android:id="@+id/image4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
  </LinearLayout>

So now,i am working with android animation Translate and it is possible to Translate image4 on to the position of image3 because they are in same parent, but i want to Translate image3/image4 on to the position of image1/image2 which is in different parent.... i have tried every layout...

回答1:

layout property clipChildren="false" works fine for me....



回答2:

Man. Create one general LinearLayout which will contains these 4 ImageViews. And then create in code create TranslateAnimation which will do path from one image to another. You must get the coordiantes of your first image(start point) and move it to second image(second point). Like overlay.



回答3:

View flipper can be used for the same.

 <ViewFlipper
            android:id="@+id/view_flipper"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_margin="6dip" >
<LinearLayout1

</LinearLayout>

<LinearLayout2

</LinearLayout>

        </ViewFlipper>
and inside code viewFlipper.showNext(); to move between views