1、效果:箭头图标由原来位置向上移动,同时改变alpha值变小。(这个效果即提示用户向上滑动屏幕)
2、布局代码activity_down.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/img_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/down"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
3、动画代码down_anim.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:shareInterpolator="true"
android:duration="1000"
>
<alpha
android:fromAlpha="1"
android:toAlpha="0.5"
android:repeatCount="infinite"
android:repeatMode="reverse"
/>
<!-- <scale
android:fromXScale="100%"
android:fromYScale="100%"
android:toXScale="80%"
android:toYScale="80%"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="reverse"
/>-->
<translate
android:fromXDelta="0%"
android:toXDelta="0%"
android:fromYDelta="0%"
android:toYDelta="-30%"
android:repeatCount="infinite"
android:repeatMode="reverse"
/>
</set>
4、activity代码
package ivan.com.appbackendtest;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class DownActivity extends AppCompatActivity {
private ImageView img_down;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_down);
img_down = (ImageView)findViewById(R.id.img_down);
AnimationSet animationSet = (AnimationSet)AnimationUtils.loadAnimation(this, R.anim.down_anim);
img_down.startAnimation(animationSet);
}
}
5、结束,动画代码的参数说明请访问 Android 三种动画详解