如何连续编写onclick动画图像?

时间:2012-11-16 05:59:49

标签: android android-animation

我的代码:

        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事件不起作用。动画也留下了痕迹。我用Google搜索并发现应用padding =“1dp”会解决,但没有运气。我的动画视图落后于视频视图的一半,视频观看的一半。请帮我解决这三个问题。我只是想从这个应用程序中做一部分功能:Bubbles,即将气泡从下往上移动并在触摸时挤压。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

您可以在onClick中使用以下代码并再次启动动画:

moveLefttoRight.setRepeatCount(Animation.INFINITE);
相关问题