android几种欢迎界面的实现 .
2014-09-04 15:02
423 查看
1.用handler的postDelayed实现
转载自:http://www.eoeandroid.com/blog-535302-2331.html
[java]
view plaincopyprint?
<SPAN style="FONT-SIZE: 18px">每个Android应用启动之后都会出现一个Splash启动界面,显示产品的LOGO、公司的LOGO或者开发者信息。如果应用程序启动时间比较长,那么启动界面就是一个很好的东西,可以让用户耐心等待这段枯燥的时间。
1.制作Splash界面
突出产品LOGO,产品名称,产品主要特色;
注明产品的版本信息;
注明公司信息或者开发者信息;
背景图片,亦可以用背景颜色代替;
2.除了等待还能做点什么
大多数的Splash界面都是会等待一定时间,然后切换到下一个界面;
其实,在这段时间里,可以对系统状况进行检测,比如网络是否通,电源是否充足;
或者,预先加载相关数据;
为了能让启动界面展现时间固定,需要计算执行以上预处理任务所花费的时间,那么:启动界面SLEEP的时间=固定时间-预处理任务时间;
3.源码示例</SPAN>
<SPAN style="FONT-SIZE: 14px">AndroidMenifest.xml
<activity android:icon="@drawable/app_icon"
android:screenOrientation="portrait"
android:name=".splashScreen"
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>
splashScreen.java
package org.wordpress.android;
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.graphics.PixelFormat;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;
import android.widget.TextView;
public class splashScreen extends Activity {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFormat(PixelFormat.RGBA_8888);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);
setContentView(R.layout.splashscreen);
//Display the current version number
PackageManager pm = getPackageManager();
try {
PackageInfo pi = pm.getPackageInfo("org.wordpress.android", 0);
TextView versionNumber = (TextView) findViewById(R.id.versionNumber);
versionNumber.setText("Version " + pi.versionName);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
new Handler().postDelayed(new Runnable() {
public void run() {
/* Create an Intent that will start the Main WordPress Activity. */
Intent mainIntent = new Intent(splashScreen.this, wpAndroid.class);
splashScreen.this.startActivity(mainIntent);
splashScreen.this.finish();
}
}, 2900); //2900 for release
}
}
splashscreen.xml
<!--
android:gravity是对元素本身说的,元素本身的文本显示在什么地方靠着换个属性设置,不过不设置默认是在左侧的。
android:layout_gravity是相对与它的父元素说的,说明元素显示在父元素的什么位置
-->
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center|center"
android:background="@drawable/home_gradient"
android:orientation="vertical">
<!--
android:scaleType是控制图片如何resized/moved来匹对ImageView的size
CENTER_INSIDE / centerInside 将图片的内容完整居中显示,通过按比例缩小或原来的size使得图片长/宽等于或小于View的长/宽
-->
<ImageView android:layout_marginTop="-60dip"
android:paddingLeft="20dip"
android:paddingRight="20dip"
android:scaleType="centerInside"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/wordpress_logo"
android:src="@drawable/wordpress_home">
</ImageView>
<!--
android:typeface 字体风格
-->
<TextView android:text="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:typeface="serif"
android:shadowDx="0"
android:shadowDy="2"
android:shadowRadius="1"
android:shadowColor="#FFFFFF"
android:textColor="#444444"
android:textSize="20dip"
android:id="@+id/versionNumber"
android:gravity="bottom">
</TextView>
</LinearLayout></SPAN>
网址:/article/4233384.html
转载自:http://www.eoeandroid.com/blog-535302-2331.html
[java]
view plaincopyprint?
<SPAN style="FONT-SIZE: 18px">每个Android应用启动之后都会出现一个Splash启动界面,显示产品的LOGO、公司的LOGO或者开发者信息。如果应用程序启动时间比较长,那么启动界面就是一个很好的东西,可以让用户耐心等待这段枯燥的时间。
1.制作Splash界面
突出产品LOGO,产品名称,产品主要特色;
注明产品的版本信息;
注明公司信息或者开发者信息;
背景图片,亦可以用背景颜色代替;
2.除了等待还能做点什么
大多数的Splash界面都是会等待一定时间,然后切换到下一个界面;
其实,在这段时间里,可以对系统状况进行检测,比如网络是否通,电源是否充足;
或者,预先加载相关数据;
为了能让启动界面展现时间固定,需要计算执行以上预处理任务所花费的时间,那么:启动界面SLEEP的时间=固定时间-预处理任务时间;
3.源码示例</SPAN>
<SPAN style="FONT-SIZE: 14px">AndroidMenifest.xml
<activity android:icon="@drawable/app_icon"
android:screenOrientation="portrait"
android:name=".splashScreen"
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>
splashScreen.java
package org.wordpress.android;
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.graphics.PixelFormat;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;
import android.widget.TextView;
public class splashScreen extends Activity {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFormat(PixelFormat.RGBA_8888);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);
setContentView(R.layout.splashscreen);
//Display the current version number
PackageManager pm = getPackageManager();
try {
PackageInfo pi = pm.getPackageInfo("org.wordpress.android", 0);
TextView versionNumber = (TextView) findViewById(R.id.versionNumber);
versionNumber.setText("Version " + pi.versionName);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
new Handler().postDelayed(new Runnable() {
public void run() {
/* Create an Intent that will start the Main WordPress Activity. */
Intent mainIntent = new Intent(splashScreen.this, wpAndroid.class);
splashScreen.this.startActivity(mainIntent);
splashScreen.this.finish();
}
}, 2900); //2900 for release
}
}
splashscreen.xml
<!--
android:gravity是对元素本身说的,元素本身的文本显示在什么地方靠着换个属性设置,不过不设置默认是在左侧的。
android:layout_gravity是相对与它的父元素说的,说明元素显示在父元素的什么位置
-->
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center|center"
android:background="@drawable/home_gradient"
android:orientation="vertical">
<!--
android:scaleType是控制图片如何resized/moved来匹对ImageView的size
CENTER_INSIDE / centerInside 将图片的内容完整居中显示,通过按比例缩小或原来的size使得图片长/宽等于或小于View的长/宽
-->
<ImageView android:layout_marginTop="-60dip"
android:paddingLeft="20dip"
android:paddingRight="20dip"
android:scaleType="centerInside"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/wordpress_logo"
android:src="@drawable/wordpress_home">
</ImageView>
<!--
android:typeface 字体风格
-->
<TextView android:text="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:typeface="serif"
android:shadowDx="0"
android:shadowDy="2"
android:shadowRadius="1"
android:shadowColor="#FFFFFF"
android:textColor="#444444"
android:textSize="20dip"
android:id="@+id/versionNumber"
android:gravity="bottom">
</TextView>
</LinearLayout></SPAN>
<span style="font-size:18px;">每个Android应用启动之后都会出现一个Splash启动界面,显示产品的LOGO、公司的LOGO或者开发者信息。如果应用程序启动时间比较长,那么启动界面就是一个很好的东西,可以让用户耐心等待这段枯燥的时间。 1.制作Splash界面 突出产品LOGO,产品名称,产品主要特色; 注明产品的版本信息; 注明公司信息或者开发者信息; 背景图片,亦可以用背景颜色代替; 2.除了等待还能做点什么 大多数的Splash界面都是会等待一定时间,然后切换到下一个界面; 其实,在这段时间里,可以对系统状况进行检测,比如网络是否通,电源是否充足; 或者,预先加载相关数据; 为了能让启动界面展现时间固定,需要计算执行以上预处理任务所花费的时间,那么:启动界面SLEEP的时间=固定时间-预处理任务时间; 3.源码示例</span> <span style="font-size:14px;">AndroidMenifest.xml <activity android:icon="@drawable/app_icon" android:screenOrientation="portrait" android:name=".splashScreen" 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> splashScreen.java package org.wordpress.android; 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.graphics.PixelFormat; import android.os.Bundle; import android.os.Handler; import android.view.WindowManager; import android.widget.TextView; public class splashScreen extends Activity { /** * Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); getWindow().setFormat(PixelFormat.RGBA_8888); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER); setContentView(R.layout.splashscreen); //Display the current version number PackageManager pm = getPackageManager(); try { PackageInfo pi = pm.getPackageInfo("org.wordpress.android", 0); TextView versionNumber = (TextView) findViewById(R.id.versionNumber); versionNumber.setText("Version " + pi.versionName); } catch (NameNotFoundException e) { e.printStackTrace(); } new Handler().postDelayed(new Runnable() { public void run() { /* Create an Intent that will start the Main WordPress Activity. */ Intent mainIntent = new Intent(splashScreen.this, wpAndroid.class); splashScreen.this.startActivity(mainIntent); splashScreen.this.finish(); } }, 2900); //2900 for release } } splashscreen.xml <!-- android:gravity是对元素本身说的,元素本身的文本显示在什么地方靠着换个属性设置,不过不设置默认是在左侧的。 android:layout_gravity是相对与它的父元素说的,说明元素显示在父元素的什么位置 --> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center|center" android:background="@drawable/home_gradient" android:orientation="vertical"> <!-- android:scaleType是控制图片如何resized/moved来匹对ImageView的size CENTER_INSIDE / centerInside 将图片的内容完整居中显示,通过按比例缩小或原来的size使得图片长/宽等于或小于View的长/宽 --> <ImageView android:layout_marginTop="-60dip" android:paddingLeft="20dip" android:paddingRight="20dip" android:scaleType="centerInside" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/wordpress_logo" android:src="@drawable/wordpress_home"> </ImageView> <!-- android:typeface 字体风格 --> <TextView android:text="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="20dip" android:typeface="serif" android:shadowDx="0" android:shadowDy="2" android:shadowRadius="1" android:shadowColor="#FFFFFF" android:textColor="#444444" android:textSize="20dip" android:id="@+id/versionNumber" android:gravity="bottom"> </TextView> </LinearLayout></span>2.用动画的方式实现
网址:/article/4233384.html
相关文章推荐
- android几种欢迎界面的实现
- Android仿人人客户端(v5.7.1)——欢迎和导引界面的编码实现
- 【Android UI设计与开发】第02期:引导界面(二)使用ViewPager实现欢迎引导页面
- Android实现定时欢迎界面
- Android实现全屏图片的欢迎界面
- 【Android UI设计与开发】第02期:引导界面(二)使用ViewPager实现欢迎引导页面
- Android开发:巧用延迟实现欢迎界面 及 摄像头预览后绘制背景标示(如坐标系、矩形框)
- 【Android UI设计与开发】第02期:引导界面(二)使用ViewPager实现欢迎引导页面
- 【Android UI设计与开发】第02期:引导界面(二)使用ViewPager实现欢迎引导页面
- android欢迎界面实现 ,线程实现和动画实现
- Android开发学习笔记(六):最简单的办法实现APP欢迎界面
- android实现开机欢迎界面
- android开机引导界面的几种实现
- android欢迎界面的编程实现[手相评分-软件实例]
- 【Android UI设计与开发】第02期:引导界面(二)使用ViewPager实现欢迎引导页面
- Android ViewPager实现应用欢迎界面
- Android仿人人客户端(v5.7.1)——欢迎和导引界面的编码实现
- 【Android UI设计与开发】第02期:引导界面(二)使用ViewPager实现欢迎引导页面
- android仿微信实现欢迎界面、介绍界面及单击按钮跳转到主界面
- android 欢迎界面的实现在一个activity中