乐乐音乐播放器 欢迎页面(二)

news/2024/10/23 7:30:14/

从开发的流程来看,引导页面应该是开发者完成相关的app所有的功能后,最后再编写的。所以现在先来写开机欢迎页面。


1. 先设置主页面 为 splash 页面。

  1. <activity android:name="com.happy.ui.SplashActivity" >
  2.             <intent-filter>
  3.                 <action android:name="android.intent.action.MAIN" />

  4.                 <category android:name="android.intent.category.LAUNCHER" />
  5.             </intent-filter>
  6.         </activity>
复制代码

2.activity_splash.xml 布局文件
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2.     xmlns:tools="http://schemas.android.com/tools"
  3.     android:layout_width="fill_parent"
  4.     android:layout_height="fill_parent"
  5.     tools:context=".SplashActivity" >

  6.     <ImageView
  7.         android:id="@+id/splash"
  8.         android:layout_width="fill_parent"
  9.         android:layout_height="fill_parent" />

  10. </RelativeLayout>
复制代码

3. 
  1. package com.happy.ui;

  2. import android.app.Activity;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.os.Handler;
  6. import android.os.Message;
  7. import android.view.Menu;
  8. import android.widget.ImageView;

  9. public class SplashActivity extends Activity {
  10.         /**
  11.          * 跳转到主页面
  12.          */
  13.         private final int GOHOME = 0;
  14.         /**
  15.          * 跳转到引导页面
  16.          */
  17.         private final int GOGUIDE = 1;
  18.         /**
  19.          * 页面停留时间 3s
  20.          */
  21.         private final int SLEEPTIME = 3000;
  22.         /**
  23.          * splash ImageView
  24.          */
  25.         private ImageView splashImageView = null;

  26.         private Handler mHandler = new Handler() {

  27.                 @Override
  28.                 public void handleMessage(Message msg) {
  29.                         switch (msg.what) {
  30.                         case GOHOME:
  31.                                 goHome();
  32.                                 break;
  33.                         case GOGUIDE:
  34.                                 goGuide();
  35.                                 break;

  36.                         default:
  37.                                 break;
  38.                         }
  39.                 }

  40.         };

  41.         @Override
  42.         protected void onCreate(Bundle savedInstanceState) {
  43.                 super.onCreate(savedInstanceState);
  44.                 setContentView(R.layout.activity_splash);
  45.                 init();
  46.                 loadData();
  47.         }

  48.         @Override
  49.         public boolean onCreateOptionsMenu(Menu menu) {
  50.                 getMenuInflater().inflate(R.menu.splash, menu);
  51.                 return true;
  52.         }

  53.         private void init() {
  54.                 splashImageView = (ImageView) findViewById(R.id.splash);
  55.         }

  56.         private void loadData() {
  57.                 splashImageView.setBackgroundResource(R.drawable.splash);
  58.                 mHandler.sendEmptyMessageDelayed(GOHOME, SLEEPTIME);
  59.         }

  60.         /**
  61.          * 跳转到引导页面
  62.          */
  63.         protected void goGuide() {

  64.         }

  65.         /**
  66.          * 跳转到主界面
  67.          */
  68.         protected void goHome() {
  69.                 Intent intent = new Intent(this, MainActivity.class);
  70.                 startActivity(intent);
  71.                 // 添加界面切换效果,注意只有Android的2.0(SdkVersion版本号为5)以后的版本才支持
  72.                 int version = Integer.valueOf(android.os.Build.VERSION.SDK);
  73.                 if (version >= 5) {
  74.                         overridePendingTransition(R.anim.anim_in, R.anim.anim_out);
  75.                 }
  76.                 finish();
  77.         }
  78. }
复制代码

4.附加动画。在 res/anim   路径下添加 动画文件

anim_in.xml


  1. <?xml version="1.0" encoding="utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android" >

  3.     <scale
  4.         android:duration="2000"
  5.         android:fromXScale="0.7"
  6.         android:fromYScale="0.7"
  7.         android:interpolator="@android:anim/accelerate_decelerate_interpolator"
  8.         android:pivotX="50%"
  9.         android:pivotY="50%"
  10.         android:toXScale="1"
  11.         android:toYScale="1" />

  12.     <alpha
  13.         android:duration="2000"
  14.         android:fromAlpha="0"
  15.         android:toAlpha="1.0" />

  16. </set>
复制代码


anim_out.xml


  1. <?xml version="1.0" encoding="utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android" >

  3.     <scale
  4.         android:duration="2000"
  5.         android:fromXScale="1"
  6.         android:fromYScale="1"
  7.         android:interpolator="@android:anim/accelerate_decelerate_interpolator"
  8.         android:pivotX="50%"
  9.         android:pivotY="50%"
  10.         android:toXScale="0.7"
  11.         android:toYScale="0.7" />

  12.     <alpha
  13.         android:duration="2000"
  14.         android:fromAlpha="1"
  15.         android:toAlpha="0" />

  16. </set>
复制代码






http://www.ppmy.cn/news/407461.html

相关文章

乐乐音乐播放器

[Android实例]乐乐音乐播放器(终)源码使用说明 转载自&#xff1a;http://www.eoeandroid.com/thread-591002-1-1.html 使用说明&#xff1a; 1. 先运行app&#xff0c;app会在内存卡创建目录 haplayer/mp3 和haplayer/ksc 等文件夹&#xff0c;然后将工程assets 里两个文件&…

乐乐音乐播放器使用

首先在此申明&#xff0c;该项目不是我做的。我只是搬运工。非常感谢作者分享全部源码出来。该项目详细解释在EOE android社区上。 地址&#xff1a; http://www.eoeandroid.com/forum.php?modviewthread&tid917012&extrapage%3D1&_dsign576de398 源码在github上…

乐乐音乐3.0

播放器写成的功能如下 &#xff1a; (1) 仿天天动听界面 (2) 界面左滑关闭页面 (3) 界面皮肤、暂时只要三套 (4) Ksc歌词【歌词平滑滚动、歌词放大缩小效果、歌词滑动快进、颜色设置、歌词字体大小设置】 (5) 桌面歌词【歌词锁定、歌词移动、歌词解锁、颜色设置、歌词…

Android本地及网络音乐播放器-播放本地音乐(一)

入职没多久&#xff0c;自学了一段时间的安卓基础知识&#xff0c;抱着巩固下基础以及学会对知识点的基本运用的初衷写了一个音乐播放器&#xff0c;因此用到的东西都是很基础的&#xff0c;功能什么的大部分都是按照自己的想法来实现的&#xff0c;如果看完感觉哪些地方写的不…

在线音乐播放项目——BY音乐

前言&#xff1a; 这是我的第一个 SSM 项目 —— BY 音乐&#xff0c;所涉及到的技术&#xff1a;Spring、SpringBoot、SpringMVC、MyBatis、BCrypt 加密、自定义拦截器、HTML、CSS、JavaScrip、jquery、ajax …… 如项目有问题 or 改进方案随时下方留言&#xff0c;感谢支持 &…

【蓝桥杯算法题】获取桌面图标名称和坐标

【蓝桥杯算法题】获取桌面图标名称和坐标 实现解释 实现 可以使用Python的第三方库pyautogui来获取桌面图标的名称和坐标。下面是一个示例代码&#xff1a; import pyautogui# 获取屏幕分辨率 screenWidth, screenHeight pyautogui.size()# 获取所有桌面图标的位置和名称 de…

FPGA基础知识-行为及建模

目录 学习目标 学习内容 1.结构化过程语句 2.过程赋值语句 3.时序控制 4.条件语句 5.多路分支语句 6.循环语句 7.顺序块和并行块 8.生成块 学习时间 学习产出 学习目标&#xff1a; 解释结构化过程always和initial在行为级建模中的重要性, 定义阻塞( blockin…

关于诺基亚60系列和symbian的基本问题

1. 什么是60系列平台&#xff1f;60系列平台是一个智能电话软件工具包&#xff0c;设备制造商可以通过授权在自己的智能电话硬件中使用这个平台。设备制造商可以使用标准的60系列软件&#xff0c;但一般情况下他们会提出需求来定制60系列软件。60系列完全使用图形化用户界面&am…