扇贝 启动页有个动画效果:
可以看出动画是慢慢的从原位置 按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,属性动画
关于 属性动画:
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>