0

Может ли кто-нибудь сказать мне, я разработал Android «Pair Game». Так что мне нужно Когда я нажимаю на кнопку изображения, он поворачивает изображение и отображает изображение животного или птицы. Пожалуйста, советую мне, как я могу это сделать?Как превратить изображение, когда я нажимаю кнопку изображения?

+0

Вы что-то пробовали раньше? – Praveenkumar

+0

s, но я не получил точного результата. – Rishi

+0

Что именно вы хотите? Должность может работать. Но вы должны настроить это с учетом ваших потребностей. – Praveenkumar

ответ

0

Попробуйте использовать эффект анимации для этого -

package com.example.flip3d; 

import android.graphics.Camera; 
import android.graphics.Matrix; 
import android.view.animation.Animation; 
import android.view.animation.Transformation; 

public class Flip3dAnimation extends Animation { 
private final float mFromDegrees; 
private final float mToDegrees; 
private final float mCenterX; 
private final float mCenterY; 
private Camera mCamera; 

public Flip3dAnimation(float fromDegrees, float toDegrees, 
    float centerX, float centerY) { 
mFromDegrees = fromDegrees; 
mToDegrees = toDegrees; 
mCenterX = centerX; 
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 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(); 

camera.rotateY(degrees); 

camera.getMatrix(matrix); 
camera.restore(); 

matrix.preTranslate(-centerX, -centerY); 
matrix.postTranslate(centerX, centerY); 

} 

} 

Я предлагаю вам передать Flip3dAnimation для этого.

Смежные вопросы