151.n1-splash页面,多种特效叠加
来源:互联网 发布:linux下如何卸载jdk 编辑:程序博客网 时间:2024/06/05 06:37
由于标题栏会影响效果,某些页面需要设置没有上面的标题栏,在activity中设置是对某一个activity有效,在application中设置是对所有的activity有效
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.ldw.news.SplashActivity" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>
动画特效有三种如下:
- 旋转 RotateAnimation
- 缩放 ScaleAnimation
- 渐变 AlphaAnimation
实现如下:
布局文件activity_splash.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/rl_root" android:background="@drawable/splash_bg_newyear" > <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/splash_horse_newyear" /></RelativeLayout>
逻辑文件SplashActivity.java
package com.ldw.news;import android.app.Activity;import android.os.Bundle;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;import android.view.animation.AnimationSet;import android.view.animation.RotateAnimation;import android.view.animation.ScaleAnimation;import android.widget.RelativeLayout;public class SplashActivity extends Activity {private RelativeLayout rl_root; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); //获取到splash页面的总布局 rl_root = (RelativeLayout) findViewById(R.id.rl_root); //spalsh进入图片的旋转动画 startAnimation(); } /* * spalsh的动画 */ private void startAnimation(){ //创建一个AnimationSet来支持多种动画特效 AnimationSet set = new AnimationSet(false); //前两个参数是旋转的角度,后四个参数是相对于自己的中心 RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); //动画维持时间 rotateAnimation.setDuration(3000); //保持最后的状态 rotateAnimation.setFillAfter(true); //旋转的过程中大小会变化 ScaleAnimation scaleAnimation = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); //动画维持时间 scaleAnimation.setDuration(3000); //保持最后的状态 scaleAnimation.setFillAfter(true); //参数为透明值由不透明到完全透明 AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1); //动画维持时间 alphaAnimation.setDuration(3000); //保持最后的状态 alphaAnimation.setFillAfter(true); //set集合中添加多个动画特效 set.addAnimation(scaleAnimation); set.addAnimation(rotateAnimation); set.addAnimation(alphaAnimation); //执行动画 rl_root.startAnimation(set); } }
0 0
- 151.n1-splash页面,多种特效叠加
- Splash 页面
- java splash screen特效
- 手机安全卫士------Splash页面
- Android Splash 页面
- zaker splash页面实现
- Splash动态页面爬虫
- N1
- android 多种特效TextView
- Android启动页面设置Splash
- 闪屏页面(Splash)开发
- 实现Splash页面版本自动更新
- Splash页面的跳转逻辑
- Safe-splash页面(1)
- 页面特效
- 页面特效
- 页面特效
- 页面特效
- 常见HTTP状态码
- Android 基础知识之Activity
- Android: DrawerLayout(抽屉导航)1
- Python学习之with语句和上下文管理器详解
- 算法导论——24.3 Dijkstra最短路径算法java实现
- 151.n1-splash页面,多种特效叠加
- java程序运行时间
- 第一课 Linux下用GDB调试程序
- 爱情-现实-钱
- 随笔
- 安卓开发:上下文菜单
- 用java写递归程序,从1打印到n
- 《软技能——代码之外的生存指南》读书笔记之职业(二)
- 一篇文章学懂Shell脚本