【问题标题】:How to flip image in android如何在android中翻转图像
【发布时间】:2011-12-08 17:18:00
【问题描述】:

我有 1 张图片,我想点击该图片,然后它会显示放置在该图片中的文本(图片中的数字),例如 30 秒,30 秒后它会回到原始位置或原始状态。 它是如何在android中发生的。

点击图片前......点击图片时(翻转图片)......30秒后图片自动回到位置1。

状态 1:

不显示任何仅显示图像的文本

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

状态 3: 30秒后自动翻转原位置或状态1。

...

注意:

如何让翻转的图像保持 30 秒

什么时候,我用这个。

<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>

在图片点击状态下只能通过翻转图片来显示两个图片的数量。 任何人对此有想法,请发表评论。

【问题讨论】:

    标签: android flip


    【解决方案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
    
            }
        });
    

    【讨论】:

    • 通过 filping 使用 ViewFliper 是不是最好的主意?你知道如何翻转图像吗?就像我的图片一样。
    • 如何保持 30 秒翻转图像 - 使用 new Handler().postDelayed
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 2012-12-02
    • 2019-04-03
    • 2022-11-30
    相关资源
    最近更新 更多