我们今天来说说怎么样用3D页面跳转。
java代码:
复制代码
java代码:
复制代码
java代码:
复制代码
转自:
http://www.eoeandroid.com/thread-92161-1-1.html
java代码:
- package eoe.demo;
-
-
- 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);
- }
- }
本帖最后由 yida 于 2011-7-29 15:52 编辑 java代码:
java代码:
|
- <?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>
java代码:
- <?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>