[英]How to put image on top of textview and start animation of moving from left to right?
I need to implement some design in my Android App that put an image on top of a textview and move from left to right to mimic some refreshing effect like shown in the picture below 我需要在Android应用程序中实现一些设计,该设计将图像放在textview的顶部,并从左向右移动以模仿一些刷新效果,如下图所示
Notice "of" is covered now. 注意“ of”已经覆盖。 And the image move to right continuously, you will see refresh effect. 并且图像连续右移,您将看到刷新效果。 The image is below 图片在下面
I know there is a library that the owner didn't maintain any more https://github.com/RomainPiel/Titanic/blob/master/library/src/main/java/com/romainpiel/titanic/library/Titanic.java but thinking if there is more elegant or simple way to achieve such effect since this is only one dimension movement. 我知道有一个所有者不再维护的库https://github.com/RomainPiel/Titanic/blob/master/library/src/main/java/com/romainpiel/titanic/library/Titanic.java但请考虑是否存在更优雅或更简单的方法来实现这种效果,因为这只是一维运动。
Create a directory anim inside the res directory and put this as slide.xml 在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>
Step 2 第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.