【问题标题】:Making ImageView align right of screen by Translate animation通过翻译动画使 ImageView 对齐屏幕右侧
【发布时间】:2015-10-16 18:11:40
【问题描述】:

ImageView 大于屏幕宽度。我希望它向左移动(平移),因此它的右侧最终与其父级(屏幕)的右侧对齐。

.______.                         .______.            
|      |                         |      |
|...............         ................
.     image    .   -->   .    image     .
................         ................
|______|                         |______|

mv_anim.xml

<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
  android:toXDelta="-100%p"
  android:duration="50000"
  android:repeatMode="reverse"
  android:repeatCount="infinite">
</translate>
</set>

我想我可以通过代码将toXDleta 设置为-(imageWidth - screenWidth) 来做到这一点。

但我想保持一切简单,根本不使用代码。有没有更简单的方法来实现这一点,只使用 XML 动画文件?

【问题讨论】:

    标签: android alignment android-animation translate-animation


    【解决方案1】:

    您的ImageView 不大于屏幕宽度。一切都包含在Window(又名屏幕)的范围内。 ImageView 中的图像已关闭,因为它太大了。使用setScaleType(FIT_END) 放置您的图像。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-20
      • 2014-10-03
      • 1970-01-01
      • 1970-01-01
      • 2017-04-27
      • 2013-02-18
      • 2016-05-22
      相关资源
      最近更新 更多