Android Autoscroll imageview

前端 未结 3 1125
囚心锁ツ
囚心锁ツ 2021-02-06 15:30

In my activity I have just an ImageView. In it, the src is a picture that is a lot bigger than the screen. I want the picture to scroll slooooowly from left to right until it re

3条回答
  •  迷失自我
    2021-02-06 16:03

    Exemple :

    private Animation           _translateAnimation;
    private ImageView       _image;
    
    _image = (ImageView)findViewById(R.id.yourimage);
    
    _translateAnimation = new TranslateAnimation(TranslateAnimation.ABSOLUTE, 0f, TranslateAnimation.ABSOLUTE, 100f, TranslateAnimation.ABSOLUTE, 0f, TranslateAnimation.ABSOLUTE, 0f);
    _translateAnimation.setDuration(10000);
    _translateAnimation.setRepeatCount(-1);
    _translateAnimation.setRepeatMode(Animation.REVERSE);
    _translateAnimation.setInterpolator(new LinearInterpolator());
    _image.setAnimation(_translateAnimation);
    

    This will make _linearLoading translate slowly right and left and right and left...

    More duration = more slowly

    TranslateAnimation.ABSOLUTE = Work with the position of the image TranslateAnimation.RELATIVE_TO_PARENT = Work with the parent layout ...

    The method TranslateAnimation(start x, end x, start y, end y)

    play with that

提交回复
热议问题