#引导界面滑动动画效果
#需求:
打开app引导页图片产生滑动动画效果,根据需要将图片设置渐变、滑动等效果。
#逻辑代码
public class MainActivity extends AppCompatActivity {
private ImageView ivImg;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ivImg=findViewById(R.id.iv_main_img);
ivImg.startAnimation(AnimationUtils.
loadAnimation(this, R.anim.anim_activity_welcome_set));
}
}
#layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.zzs.splashdemo.MainActivity">
<ImageView
android:id="@+id/iv_main_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/logo_img" />
</RelativeLayout>
#res/anim/anim_activity_welcome_set.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<scale
android:duration="100"
android:fillAfter="true"
android:fromXScale="100%"
android:fromYScale="100%"
android:toXScale="130%"
android:toYScale="100%"></scale>
<alpha
android:duration="3000"
android:fillAfter="true"
android:fromAlpha="0.4"
android:toAlpha="1.0"></alpha>
<translate
android:duration="3000"
android:fillAfter="true"
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="-30%p"
android:toYDelta="0"></translate>
</set>