2012-11-16 77 views
0

我的代碼:如何寫onclick連續動畫圖片?

 moveBottomtoTop = new TranslateAnimation(0, 0, 320, -320); 
     moveBottomtoTop.setDuration(1000); 
     moveBottomtoTop.setRepeatCount(-1); 
     moveBottomtoTop.setFillAfter(false); 

     imageView01.startAnimation(moveBottomtoTop); 

     imageView01.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 
       imageView01.setVisibility(View.INVISIBLE); 
      } 
     }); 

我的XML:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MainActivity" > 

    <LinearLayout android:id="@+id/video_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@null"> 

    <VideoView 
     android:id="@+id/surface_view" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"/> 

    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/bubbles_layout" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@null" 
     android:layout_gravity="bottom"> 

    <ImageButton 
     android:id="@+id/l01" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/pressed01" 
     android:padding="1dp" 
     android:contentDescription="@string/cont_desc"/> 

    </LinearLayout> 

</FrameLayout> 

enter image description here enter image description here

但onclick事件不起作用。動畫也留下了痕跡。我一直在搜索它,發現應用填充=「1dp」將解決,但沒有運氣。而且我的動畫視圖比videoview和half above videoview落後一半。請幫我解決這三個問題。我只想從這個應用程序中完成一部分功能:Bubbles,即,當觸摸時將氣泡從下向上移動並擠出壁球。 在此先感謝。

回答

0

您可以使用裏面的onClick下面的代碼,並再次啓動動畫:

moveLefttoRight.setRepeatCount(Animation.INFINITE); 
+0

這不起作用 –