序言
好久没有写博客了,真是越来越懒了,还是要改变!今天学习了很有可能会应用到工作中的动画效果。
效果图
实现思路
LoginActivity 通过转场动画跳转到 MainActivity :
- 在 LoginActivity 中确定动画的开始位置坐标,并通过 intent 传递给 MainActivity。
- MainActivity 拿到动画起始位置执行动画,如果需要 finish 掉 LoginActivity ,在 MainActivity 动画执行结束时 finish 掉。
- MainActivity 的 window 背景需要设置为透明,并且 根布局 background 需要设置为非透明的。
- 动画执行结束销毁 LoginActivity ,采用本地广播方式。
实现代码
LoginActivity :
activity_login.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:background="@mipmap/login_bg"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"