Translate Layout left to right

I tried to make a layout translation animate with this. But it only translate layout from left to right. But I need to translate right to left. So how should I do that?

aLayout.animate()
    .translationX(bLrLayout.getHeight())
    .alpha(0.0f)
    .setDuration(3000);

Upvotes: 1

Views: 192

Answers (2)

ashakirov
ashakirov

Reputation: 12350

But I need to translate right to left.

just use negative number as translationX parameter

aLayout.animate()
    .translationX(-1000)
    .alpha(0.0f)
    .setDuration(3000);

Upvotes: 1

Jayanth
Jayanth

Reputation: 6277

you can do something like this

ObjectAnimator anim = ObjectAnimator.ofFloat(this, "translationX", 0, bLrLayout.getHeight()); 
anim.start();

and then if you want to return back

ObjectAnimator anim = ObjectAnimator.ofFloat(this, "translationX", bLrLayout.getHeight(), 0); 
anim.start();

Upvotes: 0

Related Questions