3D魔方动画在Android中 [英] 3d Cube Animation in Android

查看:296
本文介绍了3D魔方动画在Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Android的3D立方体过渡更改视图或活动。我搜索谷歌很多办法,但无法找到Android的任何有用的资源。 我发现在店里玩一些应用程序与我改变观点或活动预期的动画。我期望的输出画面将是这样的:

I want 3d cube transition change view or activity in android. I am searching google lot of ways but, could not find any useful resource in android. I have found some apps in play shop with my expected animation for change view or activity. My expected output screen would be like:

我试着用之间的转换,但不能得到预期的结果。通过搜索我之间找到视图或活动的唯一动画3D效果的filp。

I tried with transitions between but couldn't get expected result. By searching i find only animation 3d effect filp between view or activity.

任何一个可以帮助我如何获得观点或活动之间的3D立方体过渡?

can any one help me with how to get 3d cube transition between views or activities?

推荐答案

导入这个项目物业项目,并标记为图书馆和它添加到乌拉圭回合的项目

Import this Project and mark as Library in project property and add it to ur project

创建活动乌尔这样

    package com.example.testcube;


import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.jfeinstein.jazzyviewpager.JazzyViewPager;
import com.jfeinstein.jazzyviewpager.JazzyViewPager.TransitionEffect;

public class MainActivity extends Activity {

    private JazzyViewPager vpage;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Set window fullscreen and remove title bar, and force landscape orientation
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_main);
        setupJazziness(TransitionEffect.CubeOut);
    }

    private void setupJazziness(TransitionEffect effect) {
        vpage = (JazzyViewPager) findViewById(R.id.jazzy_pager);
        vpage.setTransitionEffect(effect);
        vpage.setAdapter(new MainAdapter());
        vpage.setPageMargin(0);
    }

    private class MainAdapter extends PagerAdapter {
        @Override
        public Object instantiateItem(ViewGroup container, final int position) {
            TextView text = new TextView(MainActivity.this);
            text.setGravity(Gravity.CENTER);
            text.setTextSize(30);
            text.setTextColor(Color.WHITE);
            text.setText("Page " + position);
            text.setPadding(30, 30, 30, 30);
            int bg = Color.rgb((int) Math.floor(Math.random()*128)+64, 
                    (int) Math.floor(Math.random()*128)+64,
                    (int) Math.floor(Math.random()*128)+64);
            text.setBackgroundColor(bg);
            container.addView(text, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            vpage.setObjectForPosition(text, position);
            return text;
        }
        @Override
        public void destroyItem(ViewGroup container, int position, Object obj) {
            container.removeView((View) obj);
        }
        @Override
        public int getCount() {
            return 10;
        }
        @Override
        public boolean isViewFromObject(View arg0, Object arg1) {
            return arg0 == arg1;
        }       
    }

}

和在UR活性XML应该是

and in ur activity xml should be

<com.jfeinstein.jazzyviewpager.JazzyViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/jazzy_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />

这篇关于3D魔方动画在Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆