J'ai une mise en page assez complexe. J'utilise une disposition relative en tant que racine, puis à l'intérieur de celle-ci, j'ai quelques vues de la table et d'autres imbrications. Lorsque j'anime une image-image entre ces mises en page mes clips d'images. J'ai un arrière-plan sur la mise en page parente et l'animation semble être sous-tendue. J'ai mis android: clipChildren = "false" et android: clipToPadding = "false" sur toutes les mises en page. J'ai également défini anim.setZAdjustment (Animation.ZORDER_TOP); sur toutes mes animations. Qu'est-ce que je fais mal?Clipping d'animation Android lorsque vous passez entre les mises en page
EDIT: J'ai trouvé au moins 2 bugs jusqu'à présent. android: background = avec une couleur hexadécimale provoque des problèmes d'animation majeurs. Les dispositions de table semblent également avoir un regoin sous elles qui cause la coupure. Je vois aussi la même chose avec framelayouts. J'ajouterai une réponse une fois que je ferai fonctionner mes choses comme je le veux. J'ai le sentiment d'utiliser uniquement des dispositions linéaires, c'est la solution.
Voici un exemple de code qui génère le problème. Si vous supprimez les deux dispositions relatives aux enfants, l'animation se termine comme prévu.
Java:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView imageViewtop = (ImageView) findViewById(R.id.ImageView01);
imageViewtop.setOnClickListener(btnCardListener);
}
private OnClickListener btnCardListener = new OnClickListener() {
public void onClick(View v) {
ImageView ImageView03 = (ImageView) findViewById(R.id.ImageView03);
ImageView ImageView05 = (ImageView) findViewById(R.id.ImageView05);
int[] playLoc = { 0, 0 };
int[] botLoc = { 0, 0 };
ImageView05.getLocationOnScreen(playLoc);
ImageView03.getLocationOnScreen(botLoc);
int xMove = playLoc[0] - botLoc[0];
int yMove = playLoc[1] - botLoc[1];
AnimationSet animSet = new AnimationSet(true);
RotateAnimation ranim = new RotateAnimation(0f, 180f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f); // , 200, 200); //
// canvas.getWidth()
// 2, canvas.getHeight()/2);
ranim.setDuration(400);
ranim.setInterpolator(new DecelerateInterpolator());
TranslateAnimation transAnim = new TranslateAnimation(
Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, xMove, // +80.0f,
Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, yMove // -100.0f
);
transAnim.setInterpolator(new DecelerateInterpolator()); // AccelerateInterpolator
// ,
// LinearInterpolator
transAnim.setZAdjustment(Animation.ZORDER_TOP);
transAnim.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
ImageView ImageView03 = (ImageView) findViewById(R.id.ImageView03);
ImageView ImageView05 = (ImageView) findViewById(R.id.ImageView05);
ImageView05.setVisibility(View.VISIBLE);
ImageView03.setVisibility(View.INVISIBLE);
}
public void onAnimationRepeat(Animation animation) {
}
});
transAnim.setDuration(1000);
// Order matters...
animSet.addAnimation(ranim);
animSet.addAnimation(transAnim);
ImageView03.startAnimation(animSet);
}
};
XML:
<RelativeLayout android:id="@+id/relativeParentLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:clipToPadding="false">
<RelativeLayout android:id="@+id/relativeParentLayout1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="150dip" android:background="#440000"
android:layout_alignParentTop="true" android:clipChildren="false"
android:clipToPadding="false">
<ImageView android:layout_height="wrap_content" android:id="@+id/ImageView01"
android:layout_width="wrap_content" android:src="@drawable/card_back"
android:layout_weight="0" android:layout_alignParentTop="true" />
<ImageView android:layout_height="wrap_content" android:id="@+id/ImageView03"
android:layout_width="wrap_content" android:src="@drawable/card_back"
android:layout_weight="0" android:layout_gravity="center_vertical"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout android:id="@+id/relativeParentLayout2"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="150dip" android:background="#000044"
android:layout_alignParentBottom="true" android:clipChildren="false"
android:clipToPadding="false">
<ImageView android:layout_height="wrap_content"
android:layout_below="@+id/LinearLayout01" android:id="@+id/ImageView05"
android:layout_width="wrap_content" android:src="@drawable/card_back"
android:layout_weight="0" android:layout_alignParentBottom="true" />
</RelativeLayout>
</RelativeLayout>
http://stackoverflow.com/questions/2554871/android-how-to-position-view-off-screen/2564751#2564751 Correction d'un problème d'écrêtage; Je ne sais pas si cela va résoudre votre problème ou non. –
A mi-chemin à travers ce regard et juste remarqué qu'il a plus d'un an! Pourquoi est-il proche du haut de la liste des questions Android? –