[英]How to put image on top of textview and start animation of moving from left to right?
我需要在Android应用程序中实现一些设计,该设计将图像放在textview的顶部,并从左向右移动以模仿一些刷新效果,如下图所示
注意“ of”已经覆盖。 并且图像连续右移,您将看到刷新效果。 图片在下面
我知道有一个所有者不再维护的库https://github.com/RomainPiel/Titanic/blob/master/library/src/main/java/com/romainpiel/titanic/library/Titanic.java但请考虑是否存在更优雅或更简单的方法来实现这种效果,因为这只是一维运动。
在res目录中创建一个目录动画,并将其放置为slide.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<translate
android:fromXDelta="0%p"
android:toXDelta="75%p"
android:duration="800" />
</set>
第2步
// Refer the ImageView like this
imageView = (ImageView) findViewById(R.id.img);
// Load the animation like this
animSlide = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.slide);
// Start the animation like this
imageView.startAnimation(animSlide);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.