iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >android 3d页面跳转
  • 187
分享到

android 3d页面跳转

跳转页面android 2023-01-31 02:01:08 187人浏览 泡泡鱼

Python 官方文档:入门教程 => 点击学习

摘要

package cn.com; import Android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.ViewGr

package cn.com;
import Android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
public class Layout3D extends Activity {
 private int mCenterX = 160;
 private int mCenterY = 0;
 
 private ViewGroup layout1;
 private ViewGroup layout2;
 
 @Override
 public void onCreate(Bundle savedInstanceState) {
  
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  
  layout1 = (ViewGroup) findViewById(R.id.layout1);
  Button b1 = (Button) findViewById(R.id.button1);
  b1.setEnabled(true);
  b1.setOnClickListener(new Button.OnClickListener() {
   public void onClick(View v) {
    leftMoveHandle();
    v.setEnabled(false);
   }
  });
 }
 public void jumpToLayout1(Rotate3d leftAnimation) {
  setContentView(R.layout.main);
  layout1 = (ViewGroup) findViewById(R.id.layout1);
  layout1.startAnimation(leftAnimation);
  Button b1 = (Button) findViewById(R.id.button1);
  b1.setEnabled(true);
  b1.setOnClickListener(new Button.OnClickListener() {
   public void onClick(View v) {
    leftMoveHandle();
   }
  });
 }
 public void jumpToLayout2(Rotate3d rightAnimation) {
  setContentView(R.layout.mylayout);
  layout2 = (ViewGroup) findViewById(R.id.layout2);
  layout2.startAnimation(rightAnimation);
  Button b2 = (Button) findViewById(R.id.button2);
  b2.setEnabled(true);
  b2.setOnClickListener(new Button.OnClickListener() {
   public void onClick(View v) {
    rightMoveHandle();
   }
  });
 }
 public void leftMoveHandle() {
  Rotate3d leftAnimation = new Rotate3d(0, -90, 0, 0, mCenterX, mCenterY);
  Rotate3d rightAnimation = new Rotate3d(90, 0, 0.0f, 0.0f, mCenterX, mCenterY);
  leftAnimation.setFillAfter(true);
  leftAnimation.setDuration(1000);
  rightAnimation.setFillAfter(true);
  rightAnimation.setDuration(1000);
  layout1.startAnimation(leftAnimation);
  jumpToLayout2(rightAnimation);
 }
 public void rightMoveHandle() {
  Rotate3d leftAnimation = new Rotate3d(0, 90, 0, 0, mCenterX, mCenterY);
  Rotate3d rightAnimation = new Rotate3d(-90, 0, 0.0f, 0.0f, mCenterX,mCenterY);
  leftAnimation.setFillAfter(true);
  leftAnimation.setDuration(1000);
  rightAnimation.setFillAfter(true);
  rightAnimation.setDuration(1000);
  layout2.startAnimation(rightAnimation);
  jumpToLayout1(leftAnimation);
 }
}
package cn.com;
import android.graphics.Camera;
import android.graphics.Matrix;
import android.view.animation.Animation;
import android.view.animation.TransfORMation;
public class Rotate3d extends Animation {
 private float mFromDegree;
 private float mToDegree;
 private float mCenterX;
 private float mCenterY;
 private float mLeft;
 private float mTop;
 private Camera mCamera;
 private static final String TAG = "Rotate3d";
 public Rotate3d(float fromDegree, float toDegree, float left, float top,
   float centerX, float centerY) {
  this.mFromDegree = fromDegree;
  this.mToDegree = toDegree;
  this.mLeft = left;
  this.mTop = top;
  this.mCenterX = centerX;
  this.mCenterY = centerY;
 }
 @Override
 public void initialize(int width, int height, int parentWidth,
   int parentHeight) {
  super.initialize(width, height, parentWidth, parentHeight);
  mCamera = new Camera();
 }
 @Override
 protected void applyTransformation(float interpolatedTime, Transformation t) {
  final float FromDegree = mFromDegree;
  float degrees = FromDegree + (mToDegree - mFromDegree)
    * interpolatedTime;
  final float centerX = mCenterX;
  final float centerY = mCenterY;
  final Matrix matrix = t.getMatrix();
  if (degrees <= -76.0f) {
   degrees = -90.0f;
   mCamera.save();
   mCamera.rotateY(degrees);
   mCamera.getMatrix(matrix);
   mCamera.restore();
  } else if (degrees >= 76.0f) {
   degrees = 90.0f;
   mCamera.save();
   mCamera.rotateY(degrees);
   mCamera.getMatrix(matrix);
   mCamera.restore();
  } else {
   mCamera.save();
   //
   mCamera.translate(0, 0, centerX);
   mCamera.rotateY(degrees);
   mCamera.translate(0, 0, -centerX);
   mCamera.getMatrix(matrix);
   mCamera.restore();
  }
  matrix.preTranslate(-centerX, -centerY);
  matrix.postTranslate(centerX, centerY);
 }
}
 
 
package cn.com;
import android.app.Activity;
import android.util.Log;
import android.view.MotionEvent;
import android.view.GestureDetector.OnGestureListener;
public class FlingGuest implements OnGestureListener {
 Activity activity;
 int VALUE_DISTANCE = 100;
 int VALUE_SPEED = 20;
 public FlingGuest(Activity a) {
  activity = a;
 }
 // 用户轻触触摸屏,由1个MotionEvent ACTION_DOWN触发
 public boolean onDown(MotionEvent e) {
  Log.d("TAG", "[+++++++++++][onDown]");
  return true;
 }
 // e1, the begin of ACTION_DOWN MotionEvent
 // e2, the end of ACTION_DOWN MotionEvent
 // velocityX, the motion speed in X
 // velocityY:the motion speed in y
 // 用户按下触摸屏、快速移动后松开,由1个MotionEvent ACTION_DOWN,
 // 多个ACTION_MOVE, 1个ACTION_UP触发
 // e1:第1个ACTION_DOWN MotionEvent
 // e2:最后一个ACTION_MOVE MotionEvent
 // velocityX:X轴上的移动速度,像素/秒
 // velocityY:Y轴上的移动速度,像素/秒
 // 触发条件 :
 // X轴的坐标位移大于VALUE_DISTANCE,且移动速度大于VALUE_SPEED个像素/秒
 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
  if((e1.getX() - e2.getX() > VALUE_DISTANCE) && Math.abs(velocityX) > VALUE_SPEED) {
   ((Layout3D) activity).leftMoveHandle();
  }
  else if ((e2.getX() - e1.getX() > VALUE_DISTANCE) && Math.abs(velocityX) > VALUE_SPEED) {
   ((Layout3D) activity).rightMoveHandle();
  }
  return true;
 }
 // 用户长按触摸屏,由多个MotionEvent ACTION_DOWN触发
 public void onLongPress(MotionEvent e) {
  Log.d("TAG", "[+++++++++++][onLongPress]");
 }
 // 用户按下触摸屏,并拖动,由1个MotionEvent ACTION_DOWN, 多个ACTION_MOVE触发
 public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
   float distanceY) {
  Log.d("TAG", "[+++++++++++][onScroll]");
  return true;
 }
 // 用户轻触触摸屏,尚未松开或拖动,由一个1个MotionEvent ACTION_DOWN触发
 // 注意和onDown()的区别,强调的是没有松开或者拖动的状态
 public void onShowPress(MotionEvent e) {
  Log.d("TAG", "[+++++++++++][onShowPress]");
 }
 // 用户(轻触触摸屏后)松开,由一个MotionEvent ACTION_UP触发
 public boolean onSingleTapUp(MotionEvent e) {
  Log.d("TAG", "[+++++++++++][onSingleTapUp]");
  return true;
 }
}
 
xml:
 
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout  xmlns:android="Http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
 android:id="@+id/layout1"
 android:layout_height="fill_parent"
 android:background="@drawable/black">
 
 <Button android:id="@+id/button1"
     android:layout_width="118px"
  android:layout_height="wrap_content"
  android:text="Go to Layout2"/>
  
 <TextView android:id="@+id/text1"
     android:textSize="24sp"
  android:layout_width="186px"
  android:layout_height="29px"
  android:text="@string/layout1"
  android:layout_below="@+id/button1"/>
  
</RelativeLayout>
 
 
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
 android:id="@+id/layout2"
 android:layout_height="fill_parent"
 android:background="@drawable/white">
 <Button android:id="@+id/button2"
     android:layout_width="118px"
  android:layout_height="wrap_content"
  android:text="Go to Layout1">
 </Button>
 <TextView android:id="@+id/text2"
     android:textSize="24sp"
  android:layout_width="186px"
  android:layout_height="29px"
  android:textColor="@drawable/black"
  android:text="@string/layout2"
  android:layout_below="@+id/button2">
 </TextView>
</RelativeLayout>
 
 

--结束END--

本文标题: android 3d页面跳转

本文链接: https://www.lsjlt.com/news/186977.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • android 3d页面跳转
    package cn.com; import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.ViewGr...
    99+
    2023-01-31
    跳转 页面 android
  • Android 实现页面跳转
    android使用Intent来实现页面跳转,Intent通过startActivity(Intent intent)或startActivityForResult(Intent intent,int resquestCode)方法来启动A...
    99+
    2023-05-30
    android 页面 跳转
  • Android实现页面跳转
    本文实例为大家分享了Android实现页面跳转的具体代码,供大家参考,具体内容如下 一. Android实现页面跳转有两种方式,一种为.MainActivity跳转;第二种是Rela...
    99+
    2024-04-02
  • Android Studio 点击按钮实现页面跳转、网页跳转
    页面跳转、网页跳转 1)页面跳转 Btn1=findViewById(R.id.btn_1); Btn1.setOnClickListener(new View.OnClickListe...
    99+
    2023-09-17
    android studio android kotlin
  • jquery实现登陆跳转页面跳转页面跳转
    在Web开发中,很常见的一种需求是用户通过输入账号和密码完成登陆操作后,跳转到不同的页面。这一过程中需要用到Javascript库中非常流行的jQuery来实现。jQuery是一个快速、简洁的JavaScript库,其设计思想是“写更少,做...
    99+
    2023-05-25
  • android如何实现页面跳转
    Android中实现页面跳转主要有两种方式:隐式跳转和显式跳转。1. 隐式跳转:隐式跳转是指通过指定Intent的Action来进行...
    99+
    2023-08-19
    android
  • Android studio 按钮点击页面跳转
    (1)先创建一个要跳转的页面,即一个新的页面,该页面是点击之后跳转的。 步骤:app--->src-->main-->res-->layout(右击)-->New-->Activity-->Empty Activity  创建好以...
    99+
    2023-10-03
    java android-studio
  • golang 页面跳转
    最近想学习golang,发现golang不仅是一门语言,还可以用来进行web开发。在这里我想分享一下关于golang页面跳转的知识。在golang中,我们可以使用net/http来实现web编程,其中包括页面跳转。下面是具体实现步骤:1.导...
    99+
    2023-05-19
  • android跳转页面的方法有哪些
    Android跳转页面的方法有以下几种:1. 使用Intent:可以通过Intent来实现页面之间的跳转。可以使用隐式Intent或...
    99+
    2023-09-23
    android
  • android简单页面跳转怎么设置
    在Android中实现页面跳转需要使用Intent来进行页面之间的跳转。以下是一个简单的页面跳转示例:1. 首先,在AndroidM...
    99+
    2023-08-18
    android
  • android studio实现简单的页面跳转
    运用intent组件实现简单的跳转 主页面 Button button1,button2,button3; //xml文件定义的id @Override protected void onCreate(Bundle savedI...
    99+
    2023-10-11
    android studio android java
  • android页面跳转的方法有哪些
    Android页面跳转有多种方法,包括:1. 使用Intent进行跳转:通过创建一个Intent对象,并指定目标页面的类名或Action,然后调用startActivity方法启动目标页面。2. 使用显式Intent跳转:通过创建一个I...
    99+
    2023-08-11
    android
  • PHP页面跳转教程:如何实现页面跳转到新页面
    标题:PHP页面跳转教程:如何实现页面跳转到新页面,需要具体代码示例 在Web开发中,页面跳转是一个常见的操作,通过页面跳转可以实现用户在不同页面间进行流畅的切换,提升用户体验和网站功...
    99+
    2024-03-04
    教程 php 页面跳转 a标签
  • Android Studio怎么实现注册页面跳转登录页面
    今天小编给大家分享一下Android Studio怎么实现注册页面跳转登录页面的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了...
    99+
    2023-06-30
  • html跳转页面怎么跳
    非常抱歉,由于您没有提供文章标题,我无法为您生成一篇高质量的文章。请您提供文章标题,我将尽快为您生成一篇优质的文章。...
    99+
    2024-05-16
  • 【快速解决】Android Button页面跳转功能
    目录 让我们直接开始 第一步:先建立一个新的activity ​编辑  第二步:打开第一个页面的Java文件MainActivity 方法一:直接跳转功能如下:  方法二:输入密码才能进行跳转功能如下: 需要注意的地方 结语 让我们直接开...
    99+
    2024-01-21
    android 1024程序员节 算法 软件开发 按钮跳转
  • Android 简单跳转页面工具有哪些
    小编给大家分享一下Android 简单跳转页面工具有哪些,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!事情起源activity 或者 fragment 每次跳转传...
    99+
    2023-06-14
  • Android导航栏页面跳转怎么设置
    在Android中,可以使用Intent来实现页面的跳转。以下是一种常见的方式: 在当前Activity中,创建一个Intent...
    99+
    2023-10-26
    android
  • android studio实现页面跳转(点击按钮)
    在已经创建的java文件MainActivity(点击app,点击java)下里面编写  package com.example.myapplication1120;import android.content.Intent;import ...
    99+
    2023-10-09
    android studio android ide
  • php超链接跳转指定页面跳转
    在网页设计中,超链接是一个经常使用的元素,它可以指向网站上的其他页面、外部链接、电子邮件地址以及其他网络资源。在本文中,我们将主要关注PHP超链接的指定页面跳转。首先,让我们看一下基本的HTML超链接,它可以指向其他网页的URL地址。例如,...
    99+
    2023-05-24
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作