相信在现在APP中为了追求更好的体验或多或少都会使用场景动画提高用户体验,本片文章算是对安卓文档Animating Views Using Scenes and Transitions的知识小结,比较基础的应用,所谓的场景动画就是在预先设置的两个界面,分别展示着不同的状态,在对容器切换状态时使用安卓提供的场景动画,就会达到一种动画般的平滑过度的效果。
1. ChangeBounds
先看一下简单的效果:
从效果看出两个图片交换位置并进行缩放的状态,看一下代码,你会发现其实这样的效果只需要几部就可实现。
首先像上面说的一样创建两个场景即两个不同状态的xml文件:
第一个场景:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="80dp"
android:layout_height="80dp"
app:srcCompat="@drawable/abc"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent" />
<ImageView
android:id=