乐乐音乐播放器 欢迎页面(2)
乐乐音乐播放器 欢迎页面(二)
1. 先设置主页面 为 splash 页面。
复制代码
2.activity_splash.xml 布局文件
复制代码
3.
复制代码
4.附加动画。在 res/anim 路径下添加 动画文件
anim_in.xml
复制代码
anim_out.xml
复制代码
从开发的流程来看,引导页面应该是开发者完成相关的app所有的功能后,最后再编写的。所以现在先来写开机欢迎页面。
1. 先设置主页面 为 splash 页面。
-
<activity android:name="com.happy.ui.SplashActivity" >
-
<intent-filter>
-
<action android:name="android.intent.action.MAIN" />
-
-
<category android:name="android.intent.category.LAUNCHER" />
-
</intent-filter>
- </activity>
2.activity_splash.xml 布局文件
-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-
xmlns:tools="http://schemas.android.com/tools"
-
android:layout_width="fill_parent"
-
android:layout_height="fill_parent"
-
tools:context=".SplashActivity" >
-
-
<ImageView
-
android:id="@+id/splash"
-
android:layout_width="fill_parent"
-
android:layout_height="fill_parent" />
-
- </RelativeLayout>
3.
-
package com.happy.ui;
-
-
import android.app.Activity;
-
import android.content.Intent;
-
import android.os.Bundle;
-
import android.os.Handler;
-
import android.os.Message;
-
import android.view.Menu;
-
import android.widget.ImageView;
-
-
public class SplashActivity extends Activity {
-
/**
-
* 跳转到主页面
-
*/
-
private final int GOHOME = 0;
-
/**
-
* 跳转到引导页面
-
*/
-
private final int GOGUIDE = 1;
-
/**
-
* 页面停留时间 3s
-
*/
-
private final int SLEEPTIME = 3000;
-
/**
-
* splash ImageView
-
*/
-
private ImageView splashImageView = null;
-
-
private Handler mHandler = new Handler() {
-
-
@Override
-
public void handleMessage(Message msg) {
-
switch (msg.what) {
-
case GOHOME:
-
goHome();
-
break;
-
case GOGUIDE:
-
goGuide();
-
break;
-
-
default:
-
break;
-
}
-
}
-
-
};
-
-
@Override
-
protected void onCreate(Bundle savedInstanceState) {
-
super.onCreate(savedInstanceState);
-
setContentView(R.layout.activity_splash);
-
init();
-
loadData();
-
}
-
-
@Override
-
public boolean onCreateOptionsMenu(Menu menu) {
-
getMenuInflater().inflate(R.menu.splash, menu);
-
return true;
-
}
-
-
private void init() {
-
splashImageView = (ImageView) findViewById(R.id.splash);
-
}
-
-
private void loadData() {
-
splashImageView.setBackgroundResource(R.drawable.splash);
-
mHandler.sendEmptyMessageDelayed(GOHOME, SLEEPTIME);
-
}
-
-
/**
-
* 跳转到引导页面
-
*/
-
protected void goGuide() {
-
-
}
-
-
/**
-
* 跳转到主界面
-
*/
-
protected void goHome() {
-
Intent intent = new Intent(this, MainActivity.class);
-
startActivity(intent);
-
// 添加界面切换效果,注意只有Android的2.0(SdkVersion版本号为5)以后的版本才支持
-
int version = Integer.valueOf(android.os.Build.VERSION.SDK);
-
if (version >= 5) {
-
overridePendingTransition(R.anim.anim_in, R.anim.anim_out);
-
}
-
finish();
-
}
-
}
4.附加动画。在 res/anim 路径下添加 动画文件
anim_in.xml
-
<?xml version="1.0" encoding="utf-8"?>
-
<set xmlns:android="http://schemas.android.com/apk/res/android" >
-
-
<scale
-
android:duration="2000"
-
android:fromXScale="0.7"
-
android:fromYScale="0.7"
-
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
-
android:pivotX="50%"
-
android:pivotY="50%"
-
android:toXScale="1"
-
android:toYScale="1" />
-
-
<alpha
-
android:duration="2000"
-
android:fromAlpha="0"
-
android:toAlpha="1.0" />
-
- </set>
anim_out.xml
-
<?xml version="1.0" encoding="utf-8"?>
-
<set xmlns:android="http://schemas.android.com/apk/res/android" >
-
-
<scale
-
android:duration="2000"
-
android:fromXScale="1"
-
android:fromYScale="1"
-
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
-
android:pivotX="50%"
-
android:pivotY="50%"
-
android:toXScale="0.7"
-
android:toYScale="0.7" />
-
-
<alpha
-
android:duration="2000"
-
android:fromAlpha="1"
-
android:toAlpha="0" />
-
- </set>
相关推荐
- 先先的音乐播放器 0 写在前面 1 需求分析 2 设计分析 3 实现细节
- 乐乐音乐播放器 欢迎页面(2)
- swift版QQ音乐播放器(2)
- 有没有办法控制同域名上的其他页面(非父-子)?请问上音乐播放器只同时打开一个的有关问题
- 每日写个APP_第2天——升级版音乐播放器
- struts2指定欢迎页面替action请求
- 自己动手开发音乐播放器(2)附加界面的搭建
- vue篇 2、简单的轮播图 ajax、简单的音乐播放器、计算属性computed
- 前端web页面通过VUE集成H5直播、点播播放器LivePlayer 基于VUE和webpck的前端工程 1、安装@liveqing/liveplayer 2、webpack.config.js 添加配置 3、配置template.html 4、.vue中使用liveplayer
- 咪咕音乐播放器怎么送2G流量 咪咕音乐送2G流量活动介绍
- Storyboard使用要端纪录
- 获取Root以后