2011-12-08 59 views
0

我有一个图像,我想单击该图像,然后显示放置在该图像中的文本(图片中的数字),例如30秒,30秒后回到原始位置或原始状态。 如何在Android中发生。如何在android中翻转图像

enter image description here enter image description hereenter image description here

之前点击图像......当点击图像(翻转图像)....经过30第二图像自动回到位置1

状态1 :

DONOT显示任何文本只是显示图像仅

状态2:单击该图像,翻转并显示随机生成的值。它需要(保持)时间30秒。

状态3: 经过30秒钟后自动filping原来的位置或状态1

...

注:

如何把握30秒那fliping image

何时,我正在使用这个。

<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:interpolator="@android:anim/linear_interpolator"> 

<scale 
     android:fromXScale="1.0" 
     android:toXScale="0.0" 
     android:fromYScale="1.0" 
     android:toYScale="1.0" 
     android:pivotX="50%" 
     android:pivotY="100%" 
     android:duration="500" 
     android:repeatCount="2" 
     android:repeatMode="reverse" 
     android:startOffset="400"/> 

    </set> 

在图像点击时,只有通过图像显示的图像显示编号。 任何人有这个想法背后请给予评论。

回答

1

这里是你的布局:

<ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ic_launcher" android:layout_centerInParent="true"/> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="30 sec" android:layout_centerInParent="true"/> 

</RelativeLayout> 

制作点击收听图像视图:

ImageView image = (ImageView) findViewById(R.id.imageView1); 

    image.setOnClickListener(new View.OnClickListener() 
    { 

     @Override 
     public void onClick(View v) 
     { 
      // Rotate image here 

      new Handler().postDelayed(new Runnable() 
      { 
       @Override 
       public void run() 
       { 
        // Rotate image to original position 
       } 
      }, 30000); // 30000 time in milis 

     } 
    }); 
+0

在于,使用ViewFliper通过filping或不是最好的主意?你有任何想法如何翻转图像?就像我的图片一样。 –

+0

如何保存30秒的图像 - 使用新的Handler()。postDelayed –