Android 高仿 扇贝 Splash 启动页 UI 篇

本文详细介绍如何使用视图动画和属性动画为Android应用的启动页添加放大效果,包括XML配置和代码示例,以及解决启动白屏问题的方法。

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

扇贝 启动页有个动画效果:

 

可以看出动画是慢慢的从原位置 按X,Y 比列放大。这里可以用视图动画去做,也可以用 属性动画做。

 

关于 Splsh启动页动画效果,之前 写过一篇:Android :为你的启动页面SplashActivity 添加动画的几种方法

1,视图动画

 关于视图动画:View Animation(视图动画)使用详解

res 目录下创建 anim 文件夹,xml 定义一个ScalAnimation scale.xml:

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="2500"
    android:fromXScale="1.0"
    android:fromYScale="1.0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:fillAfter = "true"
    android:toXScale="1.12"
    android:toYScale="1.12"/>

Splash 页面布局文件 activity_splash.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    >

   <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="0dp"
       android:layout_weight="1"
       >
      <ImageView
          android:id="@+id/image"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:scaleType="centerCrop"
          android:src="@drawable/splash"
          />

   </LinearLayout>

   <TextView
       android:id="@+id/splash_tv"
       android:layout_width="match_parent"
       android:padding="5dp"
       android:text="这是高仿扇贝Splash"
       android:gravity="center_vertical"
       android:layout_height="100dp"
       />

</LinearLayout>

code:

 Animation animation = AnimationUtils.loadAnimation(this,R.anim.scale);
 imageView.startAnimation(animation);

效果图:

 

 

2,属性动画

  关于 属性动画:

  Property Animation(属性动画)使用详解

  Android属性动画完全解析(上),初识属性动画的基本用法

  set.playTogether(
                ObjectAnimator.ofFloat(imageView,"alpha",0.88f,1f),
                ObjectAnimator.ofFloat(imageView, "scaleX", 1f, 1.12f),
                ObjectAnimator.ofFloat(imageView, "scaleY", 1f, 1.12f)
        );
        set.setDuration(2500);
        set.start();

动画效果和上面一样。

关于启动白屏的问题

其实扇贝启动会有一瞬间的白屏,解决方案 Splash启动页主题添加:

  <item name="android:windowFullscreen">true</item>
   <item name="android:windowIsTranslucent">true</item>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值