Android 文件夹放大缩小仿IOS融合动画效果

本文介绍了如何实现Android文件夹打开和关闭时的缩小放大动画,确保与最终位置无缝融合,避免变形。内容包括文件夹展开后的布局分析,动画过程中的背景透明度、大小位移变化,以及图标间距和文字透明度的计算。总结了做好此类动画需要注意的要点,如布局分层、起始位置计算和动画时机调整。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

效果如下,打开文件夹时从小到大与最终位置大小吻合,关闭文件夹时缩小到图标原有位置做到无缝融合效果。

 

过程分析

(一)文件展开后的布局

如上图文件夹打开后布局层次

1.最下面时背景层(背景不移动但有透明度变化)

2.文件夹编辑控件,文件夹指示器,添加应用程序控件作为倒数第二层(该层有位移,透明度,大小缩放动画)

3.文件夹内容层也带有圆角半透明白色作为背景(该层有位移,大小缩放,文件夹内图标距离移动动画)

问题:

为什么不把背景作为一层,其他的作为一层,因为加上文件夹编辑框和应用添加控件后整体时矩形,如果做缩放动画会有变形效果,另外文件夹编辑和添加应用控件有透明度变化,所以分开处理。

整体布局如下所示

<com.android.launcher3.folder.Folder xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center">

        <View
            android:id="@+id/folder_bg"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/folder_bg_color" />

        <LinearLayout
            android:id="@+id/folder"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:background="@null"
            android:gravity="center"
            android:orientation="vertical"
            android:visibility="visible">

            <com.android.launcher3.ExtendedEditText
                android:id="@+id/folder_name"
                android:layout_width="@dimen/folder_extended_edit_text_width"
                android:layout_height="@dimen/folder_exten
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值