Donc, j'ai mis en place un carrousel comme le Android 3D Carousel.android: camera.rotateY() mystérieusement oblique carrousel
Maintenant, tant que mon getChildStaticTransformation (Voir l'enfant, la transformation de transformation) Méthode ressemble à ceci:
@Override
protected boolean getChildStaticTransformation(View child, Transformation transformation) {
transformation.clear();
transformation.setTransformationType(Transformation.TYPE_MATRIX);
// Center of the view
float centerX = (float)getWidth()/2, centerY = (float)getHeight()/2;
// Save camera
mCamera.save();
// Translate the item to it's coordinates
final Matrix matrix = transformation.getMatrix();
matrix.reset();
mCamera.translate(((CarouselItem)child).getItemX(), ((CarouselItem)child).getItemY(),
((CarouselItem)child).getItemZ());
// Align the item
mCamera.getMatrix(matrix);
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
float[] values = new float[9];
matrix.getValues(values);
// Restore camera
mCamera.restore();
Matrix mm = new Matrix();
mm.setValues(values);
((CarouselItem)child).setCIMatrix(mm);
//http://code.google.com/p/android/issues/detail?id=35178
child.invalidate();
return true;
}
tout semble bien:
mais dès que je ajouter une rotation y:
@Override
protected boolean getChildStaticTransformation(View child, Transformation transformation) {
transformation.clear();
transformation.setTransformationType(Transformation.TYPE_MATRIX);
// Center of the view
float centerX = (float)getWidth()/2, centerY = (float)getHeight()/2;
// Save camera
mCamera.save();
// Translate the item to it's coordinates
final Matrix matrix = transformation.getMatrix();
matrix.reset();
mCamera.translate(((CarouselItem)child).getItemX(), ((CarouselItem)child).getItemY(),
((CarouselItem)child).getItemZ());
// rotation start
float rotationAngle = ((CarouselItem)child).getCurrentAngle();
if(rotationAngle > 90){
rotationAngle = 180 - rotationAngle;
}
if(rotationAngle < -90){
rotationAngle = 180 - rotationAngle;
rotationAngle = -1 * (360 - rotationAngle);
}
mCamera.rotateY(rotationAngle);
// rotation end
// Align the item
mCamera.getMatrix(matrix);
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
float[] values = new float[9];
matrix.getValues(values);
// Restore camera
mCamera.restore();
Matrix mm = new Matrix();
mm.setValues(values);
((CarouselItem)child).setCIMatrix(mm);
//http://code.google.com/p/android/issues/detail?id=35178
child.invalidate();
return true;
}
La position des éléments est vissé vers le haut, regardez la distance relative des éléments à l'élément central:
Je suis d'idées. Une idée d'où cela vient?
donc déplacer la ligne ** mCamera.translate (((CarouselItem) enfant) .getItemX(), ((CarouselItem) enfant) enfant .getItemY(), ((CarouselItem)) .getItemZ()); * * après ** // fin de la rotation **? – murkr
déplacer la ligne mentionnée ci-dessus n'a pas fait l'affaire. Le carrousel a l'air différent, mais toujours bizarre. Ai-je changé les mauvaises lignes? – murkr
Si j'ai d'abord la ligne pour la rotation, puis la ligne pour traduire, les éléments du carrousel sont plus éloignés et les objets montent et descendent (du centre: monter, descendre, rester, monter et descendre). – murkr