Michwii Posted January 14, 2011 Share Posted January 14, 2011 Bonjour à tous je vous explique mon problème, je souhaiterai avoir 4 petites images en bas de l'ecran. Et lorsque je touch l'ecran j'aimerai qu'elle remonte légerement vers le haut. Les images en question sont des imageView placer dans un LinearLayout. Elles sont de plus animées par une animation-list <?xml version="1.0" encoding="utf-8" ?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@drawable/icon" android:duration="500" /> <item android:drawable="@drawable/joueur" android:duration="500" /> <item android:drawable="@drawable/joueur_2" android:duration="500" /> </animation-list> Voici la classe qui gere les 4 petites images : package com.ThreadTest.Affichage; import android.content.Context; import android.graphics.Canvas; import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.Log; import android.widget.ImageView; import com.ThreadTest.main.R; public class Joueur extends ImageView { protected AnimationDrawable animation ; protected Thread currentThread ; protected int i = 0 ; public Joueur(Context context, AttributeSet attrs) { super(context, attrs); Log.e("Joueur", "Constructeur") ; // TODO Auto-generated constructor stub setBackgroundResource(R.layout.animationjoueur) ; animation = (AnimationDrawable) getBackground() ; } public void scrollToMiddle(){ while(i < 10){ layout(getLeft(), getTop()-1, getRight(), getBottom()-1) ; i++ ; } i = 0 ; } @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); } @Override public void onWindowFocusChanged(boolean hasWindowFocus) { // TODO Auto-generated method stub super.onWindowFocusChanged(hasWindowFocus); Log.e("Joueur","onWindowFocusChanged") ; animation.start() ; } } Le problème est le suivant l'image en question monte comme prevu mais elle disparait au fur et a mesure. Peut être que je me trompe complemement de méthode. Comment feriez vous pour scroller une image sur l'écran en touchant au padding (ou autre maniere)? Merci d'avance, Cordialement, Michwii Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.