简体   繁体   中英

Animation hides the image android

i used below single line code for animation to my image view in android.

Coding

        v.animate().translationXBy(1000).setDuration(5000).start();

but i hides the image. i don't want to hide my image using the above source. any helps are much welcome thanks.

Try this:

v.bringToFront();

Add this before animating.

Hope this helps

how do you want to hide your image?

you can also hide it by set 0 in alpha attribute

v.animate().alpha(0).setDuration(500).start();

EDIT

To move the view right to left without hide it at the end

You can try to use v.animate.x() instead

  1. Set the min X Position, its 0 since you want to move it to left without goes out of screen

int minXPosition = 0;

  1. Set the value how much the view move and calculate the view new X position

int moveXBy = 100;

int newXPosition = (int)view.getX()-moveXBy;

  1. Animate the view, but check the position first -> if its past your minXPosition, use the minXPosition instead

view.animate() .x(newXPosition<minXPosition?minXPosition:newXPosition) .setDuration(500) .start();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM