I want to move ImageView (man.png) from right to left in Activity class(implements Runnable). I am using Man.setTranslationX(float x); to move... Here is my code Man is not moving by run() method ..
public class PlayScreen extends Activity implements Runnable{
float ManX=100;
Thread thread=new Thread(this);
//some code here(removed)
public void ManImageView() {
Man = (ImageView)findViewById(R.id.stickman);
Man.setVisibility(ImageView.VISIBLE);
thread.start();
}
@Override
public void run(){
Man.setTranslationX(ManX);
ManX++;
try{
thread.sleep(500);}
catch{
}
}
is there any way to update ur screen continuously like invalidate(); method in View class.. or there is some problem with Thread running??? Here is .xml of ImageView
<ImageView
android:id="@+id/stickman"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="50sp"
android:layout_marginBottom="15sp"
android:src="@drawable/image1"/>
Please Help