Reputation: 34257
I want my arrows to continuously move left and right with a delay of certain milliseconds dynamically. Any clue?
Here's my code:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageView;
public class PlayWithGraphics extends Activity {
/** Called when the activity is first created. */
public final int delay = 2500;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final ImageView iv = (ImageView)findViewById(R.id.iv);
iv.setBackgroundResource(R.drawable.back_two);
new Handler().postDelayed(new Runnable(){
public void run(){
//iv.setPadding(30, 0, 10, 0);
}
}, delay);
}
}
Upvotes: 0
Views: 4306
Reputation: 50392
You could either use a translate animation and update the movement in the onRepeatListener
or put your image in a RelativeLayout
and change its margin at regular intervals.
Upvotes: 2