1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| public void translation(View view, float fromXDelta, float toXDelta, float fromYDelta, float toYDelta) {
TranslateAnimation animation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);
animation.setDuration(1000);
animation.setInterpolator(getApplicationContext(), linear_interpolator);
animation.setFillAfter(true);
animation.setFillEnabled(true);
curseur.startAnimation(animation);
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
curseur = (ImageView) findViewById(R.id.curseur);
translation(curseur, 0, 50, 0, 0);
translation(curseur, 0, 500, 0, 0); |
Partager