手机安全卫士开发系列(2)——splash界面
一、Android中的MVC
(1)activity主要用来页面的展示
(2)engine包:获取数据和展示数据(包含数据适配器)
(3)domain包:存放数据实体
第一种包结构组织关系:
第二种包结构:
利用程序的业务逻辑进行代码划分,比如QQ, qq有登陆模块,聊天模块,群组模块,qq空间模块
com.tencent.login
com.tencent.im
com.tencent.group
com.tencent.zoom
二、建立工程和包
splash主要用于闪屏的显示(包括产品logo显示,数据库初始化,获取服务器最新信息是否有新版本更新,)
市场上不少应用会在不同时间显示不同logo,这是怎么做的呢?是事先偷偷的将logo就下载好了,到了特定的某一天就会加载到该界面。
我建立的工程如下:
要注意在mainfest文件里面的路径配置:package=" " android:name=" "
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mobiesafe"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".ui.SplashActivity"
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> </manifest>
现在创建布局文件splash.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- 线性布局 -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/logo2"
android:gravity="center_horizontal"
android:orientation="vertical"
android:id="@+id/ll_splash_main"
>
<!-- 显示版本号 -->
<TextView
android:id="@+id/tv_splash_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="280dip"
android:text="版本号"
android:textColor="#FF01b6f8"
android:textSize="20sp" />
<!-- 下载进度条 -->
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dip" /> </LinearLayout>
SplashActivity
package com.meritit.mobiesafe.ui; import android.app.Activity;
import android.app.ProgressDialog;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.widget.LinearLayout;
import android.widget.TextView; import com.example.mobiesafe.R; public class SplashActivity extends Activity {
private static final String TAG = "SplashActivity";
private TextView tv_splash_version;
private LinearLayout ll_splash_main;
private ProgressDialog pd ;
private String versiontext; @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 取消标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash);
ll_splash_main = (LinearLayout) this.findViewById(R.id.ll_splash_main);
tv_splash_version = (TextView) this
.findViewById(R.id.tv_splash_version);
versiontext = getVersion();
tv_splash_version.setText(versiontext);
AlphaAnimation aa = new AlphaAnimation(0.0f, 1.0f);
aa.setDuration(2000);
ll_splash_main.startAnimation(aa); // 完成窗体的全屏显示 // 取消掉状态栏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN); } /**
* 获取当前应用程序的版本号
*
* @return
*/
private String getVersion() {
try {
//包管理服务
PackageManager manager = getPackageManager();
//第一个参数为包名
PackageInfo info = manager.getPackageInfo(getPackageName(), 0);
return info.versionName;
} catch (Exception e) { e.printStackTrace();
return "版本号未知";
}
} }
运行结果
源代码下载:http://download.csdn.net/detail/lxq_xsyu/5928701
手机安全卫士开发系列(2)——splash界面的更多相关文章
- 【手机安全卫士01】项目Splash页面的开发与设计
首先建立一个安卓的项目,然后修改manifest.xml文件,修改应用程序的logo和显示名称,效果图如下: 对应的代码如下: <?xml version="1.0" enc ...
- Android项目实战--手机卫士开发系列教程
<ignore_js_op> banner131010.jpg (71.4 KB, 下载次数: 0) 下载附件 保存到相册 2 分钟前 上传 Android项目实战--手机卫士01- ...
- hbuilder 手机app开发系列(一)
最佳答案好水啊,实在看不过眼,首先apicloud是一个框架,hbuidler是ide工具,两者没什么可比性.我来推荐一个国外免费开源的项目吧,Ionic framework,我之所以推荐它是因为它支 ...
- 【边做项目边学Android】手机安全卫士05_2:程序主界面,为每一个条目加入事件
为每一个条目加入点击事件监听器 gv_main.setOnItemClickListener(this); 须要当前Activity实现OnItemClickListener接口.同一时候实现publ ...
- Android项目实战_手机安全卫士splash界面
- 根据代码的类型组织包结构 1. 界面 com.hb.mobilesafe.activities 2. 服务 com.hb.mobilesafe.services 3. 业务逻辑 com.hb.mo ...
- 高仿QQ即时聊天软件开发系列之二登录窗口界面
继上一篇高仿QQ即时聊天软件开发系列之一开端之后,开始做登录窗口 废话不多说,先看效果,只有界面 可能还有一些细节地方没有做,例如那个LOGO嘛,不要在意这些细节 GIF虽短,可是这做起来真难,好吧因 ...
- Android项目 手机安全卫士(代码最全,注释最详细)之十二 设置中心的界面
------- 源自梦想.永远是你IT事业的好友.只是勇敢地说出我学到! ---------- 按惯例,写在前面的:可能在学习Android的过程中,大家会和我一样,学习过大量的基础知识,很多的知识点 ...
- 【Qt编程】基于Qt的词典开发系列<六>--界面美化设计
本文讲一讲界面设计,作品要面向用户,界面设计的好坏直接影响到用户的体验.现在的窗口设计基本都是扁平化的,你可以从window XP与window 8的窗口可以明显感觉出来.当然除了窗口本身的效果,窗口 ...
- Android项目实战_手机安全卫士home界面
# 安全卫士主页面# ###1.GridView控件 1.与ListView的使用方式差不多,也要使用数据适配器,通过设置android:numColumns控制显示几列 2.通过指定android: ...
随机推荐
- Centos6.5安装
前奏:CentOS 6.5下载地址http://mirror.centos.org/centos/6.5/isos/x86_64/CentOS-6.5-x86_64-bin-DVD1to2.torre ...
- 桂电在线-转变成bootstrap版
由于angularjs的不熟悉,而且SEO需要学习更多东西,于是先采用bootstrap版本,毕竟工作上也需要使用bootstrap,然后参照视频教程学习. bootstrap 基本模板 <!D ...
- C# 数据结构 线性表(顺序表 链表 IList 数组)
线性表 线性表是最简单.最基本.最常用的数据结构.数据元素 1 对 1的关系,这种关系是位置关系. 特点 (1)第一个元素和最后一个元素前后是没有数据元素,线性表中剩下的元素是近邻的,前后都有元素. ...
- css格式化排版
1,文字排版--字体 语法: body{font-family:"Microsoft Yahei";} 这里注意不要设置不常用的字体,因为如果用户本地电脑上如果没有安装你设置的字体 ...
- TMS IntraWeb 5.4.1.1 for XE6 (适配Intraweb14.0.32)
文件夹内含有我自己已经编译好的bpl,仅供大家学习使用,请支持正版!!导入ParaInstalarXE6.groupproj后,逐个编译安装即可. 链接:http://pan.baidu.com/s/ ...
- Java实现Http服务器(四)
(1)HTTPServer的监听启动 sun.net.httpserver.ServerImpl类中启动了Socket监听,ServerImpl的内部类Dispatch类启动了Http服务器的监听 / ...
- python时间处理
1.获取当前时间的两种方法: import datetime,time now = time.strftime("%Y-%m-%d %H:%M:%S") print now now ...
- win7+ubuntu双系统安装方法
转自win7+ubuntu双系统安装方法 前段时间又安装一下win7+ubuntu双系统,过段时间就会忘记,这次自己写下来,以便以后查看. 1. 先准备一个分区来安装ubuntu.在win7 ...
- eclipse 中使用等宽字体 inconsolata
一直以来,就感觉使用 eclipse 时的那几种字体很难看,而且非等宽,空格宽度很小,排版很乱. 搜索并试用了一下,发现了字体inconsolata. 这是一个很适合编程的字体,效果如下: 非常漂亮. ...
- Apache Hadoop RPC Authentication 安全绕过漏洞
漏洞名称: Apache Hadoop RPC Authentication 安全绕过漏洞 CNNVD编号: CNNVD-201308-425 发布时间: 2013-08-28 更新时间: 2013- ...