欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Android實現(xiàn)3D翻轉(zhuǎn)動畫效果-創(chuàng)新互聯(lián)

Android中并沒有提供直接做3D翻轉(zhuǎn)的動畫,所以關(guān)于3D翻轉(zhuǎn)的動畫效果需要我們自己實現(xiàn),那么我們首先來分析一下Animation 和 Transformation。

創(chuàng)新互聯(lián)建站主營海城網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,APP應(yīng)用開發(fā),海城h5小程序設(shè)計搭建,海城網(wǎng)站營銷推廣歡迎海城等地區(qū)企業(yè)咨詢

Animation動畫的主要接口,其中主要定義了動畫的一些屬性比如開始時間,持續(xù)時間,是否重復(fù)播放等等。而Transformation中則包含一個矩陣和alpha值,矩陣是用來做平移,旋轉(zhuǎn)和縮放動畫的,而alpha值是用來做alpha動畫的,要實現(xiàn)3D旋轉(zhuǎn)動畫我們需要繼承自Animation類來實現(xiàn),我們需要重載getTransformation和applyTransformation,在getTransformation中Animation會根據(jù)動畫的屬性來產(chǎn)生一系列的差值點,然后將這些差值點傳給applyTransformation,這個函數(shù)將根據(jù)這些點來生成不同的Transformation。下面是

具體實現(xiàn):


package com.example.textviewtest; 
 
import android.graphics.Camera; 
import android.graphics.Matrix; 
import android.view.animation.Animation; 
import android.view.animation.Transformation; 
 
public class Rotate3dAnimation extends Animation { 
  // 開始角度 
  private final float mFromDegrees; 
  // 結(jié)束角度 
  private final float mToDegrees; 
  // 中心點 
  private final float mCenterX; 
  private final float mCenterY; 
  private final float mDepthZ; 
  // 是否需要扭曲 
  private final boolean mReverse; 
  // 攝像頭 
  private Camera mCamera; 
 
  public Rotate3dAnimation(float fromDegrees, float toDegrees, float centerX, 
      float centerY, float depthZ, boolean reverse) { 
    mFromDegrees = fromDegrees; 
    mToDegrees = toDegrees; 
    mCenterX = centerX; 
    mCenterY = centerY; 
    mDepthZ = depthZ; 
    mReverse = reverse; 
  } 
 
  @Override 
  public void initialize(int width, int height, int parentWidth, 
      int parentHeight) { 
    super.initialize(width, height, parentWidth, parentHeight); 
    mCamera = new Camera(); 
  } 
 
  // 生成Transformation 
  @Override 
  protected void applyTransformation(float interpolatedTime, Transformation t) { 
    final float fromDegrees = mFromDegrees; 
    // 生成中間角度 
    float degrees = fromDegrees 
        + ((mToDegrees - fromDegrees) * interpolatedTime); 
 
    final float centerX = mCenterX; 
    final float centerY = mCenterY; 
    final Camera camera = mCamera; 
 
    final Matrix matrix = t.getMatrix(); 
 
    camera.save(); 
    if (mReverse) { 
      camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime); 
    } else { 
      camera.translate(0.0f, 0.0f, mDepthZ * (1.0f - interpolatedTime)); 
    } 
    camera.rotateY(degrees); 
    // 取得變換后的矩陣 
    camera.getMatrix(matrix); 
    camera.restore(); 
 
    matrix.preTranslate(-centerX, -centerY); 
    matrix.postTranslate(centerX, centerY); 
  } 
} 

當(dāng)前標(biāo)題:Android實現(xiàn)3D翻轉(zhuǎn)動畫效果-創(chuàng)新互聯(lián)
本文網(wǎng)址:http://chinadenli.net/article34/cohspe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)品牌網(wǎng)站設(shè)計面包屑導(dǎo)航營銷型網(wǎng)站建設(shè)網(wǎng)站制作微信公眾號

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)