【问题标题】:Android ImageSwitcher with vertical scroll带有垂直滚动的 Android ImageSwitcher
【发布时间】:2011-07-05 06:18:07
【问题描述】:

我尝试从 ImageSwitcher 更改滚动的艺术。 正常的 ImageSwitcher 从左到右或从右到左滚动。 但我想从上到下或从下到上滚动。 我找不到这个问题的解决方案。 谁能帮帮我。

【问题讨论】:

  • 只是一个建议。了解手势检测,并根据投掷动作,尝试在您想要的方向上制作动画,并使用脚蹼来切换图像。
  • 尝试检查我的答案。我遇到了这个问题并使用这些动画解决了它。

标签: android imageswitcher


【解决方案1】:

您可以在 SDK 中找到 slide_in_up 和 slide_out_down,请参阅platforms/[version]/data/res/anim 目录中的 XML 文件。

查看这些应该很简单,如果需要,可以使用它们来制作 slide_in_down 和 slide_out_up。

【讨论】:

    【解决方案2】:

    我知道这是一个非常古老的问题,但是...我已经通过这种方式解决了这个问题:

    将这两个文件放在您的 anim 文件夹中。

    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>
    

    然后,在您的 ActivityFragment 上,尝试执行以下操作:

    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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多