Android————制作启动页面
2013-03-05 10:49
387 查看
1、制作三张启动图片都命名为splash.png,分辨率为240*320、320*480、480*800,分别放置在drawable-ldpi、drawable-mdpi、drawable-hdpi文件夹中。
2、在layout文件夹中创建一个activity_splash.xml文件,内容如下
3、在src文件夹的架包中新建SplashActivity,代码如下
4、 修改AndroidManifest.xml文件,将启动界面Activity改为默认启动,并且设置标题栏不可见。
5、显示效果如下:
2、在layout文件夹中创建一个activity_splash.xml文件,内容如下
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="bottom|center" android:orientation="vertical" android:background="@drawable/splash"> <TextView android:id="@+id/splash_VerNumber" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="20dip" android:gravity="bottom" android:textSize="20dip" /> </LinearLayout>
3、在src文件夹的架包中新建SplashActivity,代码如下
package com.lxh.androideater; import android.app.Activity; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.os.Handler; import android.util.Log; import android.widget.TextView; public class SplashActivity extends Activity { //------------------------------------------ 变量 ------------------------------------------ //显示版本号 TextView tViewVerNumber = null; //延时跳转 Handler handler = null; JustIntoMainActivityRunnable gotoMainR = null; //------------------------------------------ 方法 ------------------------------------------ @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); //设置要显示的布局文件 setContentView(R.layout.activity_splash); try { //获取架包管理对象 PackageManager pm = getPackageManager(); //回去本项目的包信息对象 PackageInfo pi = pm.getPackageInfo("com.lxh.androideater", 0); //得到activity_splash.xml中显示版本号的TextView tViewVerNumber = (TextView) findViewById(R.id.splash_VerNumber); //pi.versionName要显示的版本信息, //即AndroidManifest.xml中的 android:versionName="1.0.0" 数据 tViewVerNumber.setText("版本号: " + pi.versionName); } catch (Exception e) { // TODO: handle exception Log.e("Error——Splash", e.getMessage()); e.printStackTrace(); } handler = new Handler(); gotoMainR = new JustIntoMainActivityRunnable(); //2500毫秒后执行JustIntoMainActivityRunnable对象的run()方法 handler.postDelayed(gotoMainR, 250000); } //------------------------------------------ 类 ------------------------------------------ /** * 进入MainActivity页面 */ class JustIntoMainActivityRunnable implements Runnable { @Override public void run() { // TODO Auto-generated method stub //创建一个Intent对象 Intent intent = new Intent(); //设置要跳转的页面对象 intent.setClass(SplashActivity.this, MainActivity.class); //跳转到MainAcitivity页面 startActivity(intent); //把本页面从栈中弹出 SplashActivity.this.finish(); } } }
4、 修改AndroidManifest.xml文件,将启动界面Activity改为默认启动,并且设置标题栏不可见。
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.lxh.androideater" android:versionCode="1" android:versionName="1.0.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".SplashActivity" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MainActivity" android:label="@string/title_activity_main" > </activity> </application> </manifest>
5、显示效果如下:
相关文章推荐
- android启动页面制作
- Android商城开发系列(二)——App启动欢迎页面制作
- Android启动页面制作
- android 启动页面的设置
- Android 嵌入式 linux 去掉启动时闪烁的光标 和制作启动LOGO
- Android - TabHost 与 Fragment 制作页面切换效果
- Android开发笔记--制作启动界面splash
- 转 IOS 启动页面制作
- android使用html+javascript来制作页面
- iOS/Android/WAP 全兼容专题页面制作方法(一)
- Android从Web页面启动App
- android 启动时出现空白带标题的页面解决办法
- 【Android 应用开发】Android中使用ViewPager制作广告栏效果 - 解决ViewPager占满全屏页面适配问题
- android 启动页面
- Android 启动界面的制作
- android 启动系统的功能页面Action
- react native Android启动页面、修改图标、修改名字、修复启动白屏
- Android中使用ViewPager制作广告栏效果 - 解决ViewPager占满全屏页面适配问题
- Qt制作简单和高级SplashScreen(程序启动页面)
- 50天iOS挑战(Swift) - 第10天:制作应用启动引导页面