1

「カード」を裏返すアニメーションを作成しました。これを実現するために、前面と背面のそれぞれで setRotationYBy() と setVisibility() を使用しました。アニメーション自体は正常に動作しますが、アニメーションの実行中に両方のカードの内容が消えます(アニメーションが終了すると再び表示されます)。cardFront.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {


            final Runnable moveMapDown = new Runnable() {
                 public void run() {
                     map.animate().y(0);
                 }
             };
             final Runnable flipCard2 = new Runnable() {
                 public void run() {
                     cardBack.setVisibility(View.VISIBLE);
                     cardFront.setVisibility(View.INVISIBLE);
                     currentFront = false;  
CardBack.animate().rotationYBy(90).setInterpolator
(new DecelerateInterpolator()).withEndAction(moveMapDown).setDuration(300);
                     cardFront.setRotationY(180);

                 }
             };
            Runnable flipCard = new Runnable() {
                 public void run() {
                     cardBack.setRotationY(-90);
                 cardFront.animate().rotationYBy(90).setInterpolator
              (new AccelerateInterpolator()).withEndAction(flipCard2).setDuration(300);

                 }
             };

            map.animate().y(-200).withEndAction(flipCard);

        }

    });

裏面のXML-Layout(表面はほぼ同じ)。

<RelativeLayout
        android:id="@+id/back"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/imageView1"
        android:layout_centerHorizontal="true"
        android:layout_centerInParent="true"
        android:layout_centerVertical="true"
        android:layout_marginTop="-18dp"
        android:background="@drawable/bgpatch"
        android:paddingBottom="16dp"
        android:paddingLeft="8dp"
        android:paddingRight="8dp"
        android:paddingTop="6dp"
        android:visibility="invisible" >

        <RelativeLayout
            android:layout_width="300dp"
            android:layout_height="288dp"
            android:background="@drawable/dayplan_element_bg" >

            <RelativeLayout
                android:id="@+id/background"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/dayplan_element_bg"
                android:paddingBottom="2dp"
                android:paddingLeft="8dp"
                android:paddingRight="8dp"
                android:paddingTop="2dp" >

                <TextView
                    android:id="@+id/backTitle"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_centerHorizontal="true"
                    android:layout_centerInParent="true"
                    android:layout_centerVertical="true"
                    android:gravity="center"
                    android:text="zusätzliche Informationen"
                    android:textAppearance="?android:textAppearanceLarge"
                    android:textColor="@android:color/primary_text_dark"
                    android:textSize="30sp"
                    android:textStyle="italic" />
            </RelativeLayout>

            <View
                android:id="@+id/view1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="-1dp"
                android:background="@drawable/shadow" />
        </RelativeLayout>
    </RelativeLayout>
4

1 に答える 1