开发者

Android ImageSwitcher with vertical scroll

开发者 https://www.devze.com 2023-03-17 13:05 出处:网络
I try to change the art of scrolling from a ImageSwitcher. The normal ImageSwitcher scroll from left to rig开发者_如何学Cht or right to left.

I try to change the art of scrolling from a ImageSwitcher. The normal ImageSwitcher scroll from left to rig开发者_如何学Cht or right to left. But I want to scroll from top to bottom or bottom to top. I din´t find a solution for this problem. Can anybody help me.


You can find slide_in_up and slide_out_down in the SDK, see XML files in the platforms/[version]/data/res/anim directory.

It should be simple to look at these and use them to make slide_in_down and slide_out_up if you need them.


I know it's a very old question, but... I've solved this issue this way:

Place those two files on your anim folder.

slide_in_right.xml

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="50%p" android:toXDelta="0"
        android:duration="@android:integer/config_shortAnimTime"/>
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
        android:duration="@android:integer/config_shortAnimTime" />
</set>

slide_out_left.xml

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="0" android:toXDelta="-50%p"
        android:duration="@android:integer/config_shortAnimTime"/>
    <alpha android:fromAlpha="1.0" android:toAlpha="0.0"
        android:duration="@android:integer/config_shortAnimTime" />
</set>

Then, on your Activity or Fragment, try to do the following:

Animation in_rl = AnimationUtils.loadAnimation(rootView.getContext(), R.anim.slide_in_right);

Animation out_rl = AnimationUtils.loadAnimation(rootView.getContext(), R.anim.slide_out_left);

mImageSwitcher.setInAnimation(in_rl);
mImageSwitcher.setOutAnimation(out_rl);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号