【问题标题】:how to flip images like 3d animation in android?如何在android中翻转像3d动画这样的图像?
【发布时间】:2011-12-01 11:11:47
【问题描述】:

我有 3d 图像,例如 1-10 张图像

其中我有 (1-5) 个从前到后的 3d 形状左侧的图像,类似地 从前到后向右病房(6-10)

如果我们看到它们,就会形成一个完整的 3d 形状,我想通过左右滑动/翻转来使用它们,以便显示该图像的完整 3d 视图。

我已经看过这个例子,但它离我的视图很远。 http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html

任何人指导我如何实现这一目标?

任何帮助将不胜感激。

【问题讨论】:

    标签: android view 3d viewflipper


    【解决方案1】:

    您可以在 Raghav Chopra 的 3D 翻转库 https://code.google.com/p/android-3d-flip-view-transition 的基础上添加逼真的 3D 翻转过渡。

    有了这个,你所要做的就是不要打电话给flipper.showNext();,而是打电话给AnimationFactory.flipTransition(flipper, FlipDirection.LEFT_RIGHT);,你就完成了。 3D动画很酷。

    许多其他教程和示例代码(包括您正在使用的那个)都不会产生可信的 3D 翻转。 y 轴上的简单旋转是不够的,请查看上面的链接(或此视频 http://youtu.be/52mXHqX9f3Y)。

    如果你想让它自动转换,只需添加一个Handler 喜欢:

    Handler handler = new Handler();
    ...
    handler.postDelayed(new Runnable() {
        AnimationFactory.flipTransition(flipper, FlipDirection.LEFT_RIGHT);
    }, 500);
    

    以上内容将无限期地不断翻阅图像(循环回到最后的第一张图像)。要停止自动转换,您可以添加一个布尔标志,在开始翻转之前检查该标志,或者保存您正在使用的Runnable 并调用handler.removeCallbacks(runnable)

    【讨论】:

      【解决方案2】:

      用于翻转的xml

      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      >
      <Button android:id="@+id/flip_me"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="Flip Me!"
      />
      <ViewFlipper android:id="@+id/details"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      >
      <TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:textStyle="bold"
      android:textColor="#FF00FF00"
      android:text="This is the first panel"
      />
      <TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:textStyle="bold"
      android:textColor="#FFFF0000"
      android:text="This is the second panel"
      />
      <TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:textStyle="bold"
      android:textColor="#FFFFFF00"
      android:text="This is the third panel"
      />
      </ViewFlipper>
      </LinearLayout>
      

      java文件

      public class FlipperDemo extends Activity {
      ViewFlipper flipper;
      @Override
      public void onCreate(Bundle icicle) {
      super.onCreate(icicle);
      setContentView(R.layout.main);
      flipper=(ViewFlipper)findViewById(R.id.details);
      Button btn=(Button)findViewById(R.id.flip_me);
      btn.setOnClickListener(new View.OnClickListener() {
      public void onClick(View view) {
      flipper.showNext();
      }
      });
      }
      }
      

      这是手动翻转

      结果是一个微不足道的活动:单击按钮,然后按顺序的下一个 TextView 是 显示,查看最后一个后环绕到第一个

      【讨论】:

      • 我知道视图翻转器的功能我的问题是如何翻转 3d 图像(帧数)以形成 3d 视图。
      • 你想要它自动翻转吗? 3D 图像?
      • 自动+手动都只是在寻找如何实现的想法?
      猜你喜欢
      • 2021-11-29
      • 2012-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多