1

私はxmlに相対レイアウトを持っています。そのビューを移動して、アニメーションのように左に移動したい(画面左まで)。完全な内部レイアウトがアニメーションのように画面の端まで移動するようにしたい

id="center" で相対レイアウトにアニメーションを入れたい

 <RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
      android:background="@drawable/img_1"

     android:layout_centerInParent="true"  

    android:id="@+id/cartoon_image"> 

  <RelativeLayout
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:background="@drawable/play_btn"
        android:orientation="horizontal"
        android:layout_centerInParent="true"
        android:id="@+id/play_btn"
       >
       <RelativeLayout
       android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="vertical"
     android:visibility="gone"

       android:gravity="center"
       android:background="@drawable/circle"
      android:id="@+id/center">


  <ImageView 
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_marginTop="15dp"
        android:background="@drawable/like_small"
        android:id="@+id/like_image_centre"

       />  

  <TextView
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_marginTop="15dp"
        android:layout_below="@+id/like_image_centre"
        android:text="36"
        android:textSize="25dp"
        android:textColor="#DF013A"
        android:id="@+id/likes_count_centre"

        />

 </RelativeLayout>
       </RelativeLayout>
  </RelativeLayout>

この問題の解決にご協力ください

4

1 に答える 1

3

アクティビティの onCreate でこのコードを試してください

この機能を変更するTranslateAnimation(fromX,toX,fromY,toY)ことで、レイアウトを動かしたいアニメーションを設定することができます。

RelativeLayout mLayout = (RelativeLayout) findViewById(R.layout.center);


    TranslateAnimation anim=new TranslateAnimation(0,80,0,0);
            anim.setDuration(1500);
            anim.setRepeatCount(Animation.INFINITE);
         // anim.setRepeatMode(Animation.INFINITE);
            anim.setRepeatMode(Animation.REVERSE);

            mLayout.setAnimation(anim);
于 2013-10-30T06:32:51.350 に答える