Android启动过程中背景图片显示
来源:互联网 发布:javascript用于flash 编辑:程序博客网 时间:2024/06/09 23:43
大部分Android App启动过程中,都会设置一个背景图片,直到App加载成功,图片消失。因此,这也是做Android App的基本技能之一。这个过程实现起来并不难。
总共需要以下内容:2个Activity,一张背景图,2个xml配置文件,String.xml,AndroidManifest写入配置信息。
1 准备一张背景图图片,命名为load,自己选择图片格式。放在drawable目录下
2 创建Load页面 LoadActivity.java及相关布局文件load.xml
LoadActivity.java
package com.timothy.load;import android.app.Activity;import android.os.Bundle;import android.content.Intent;import android.graphics.PixelFormat;import android.os.Handler;import android.view.WindowManager;public class LoadActivity extends Activity { //time for picture display private static final int LOAD_DISPLAY_TIME = 1500; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFormat(PixelFormat.RGBA_8888); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER); setContentView(R.layout.load); new Handler().postDelayed(new Runnable() { public void run() { //Go to main activity, and finish load activity Intent mainIntent = new Intent(LoadActivity.this, MainActivity.class); LoadActivity.this.startActivity(mainIntent); LoadActivity.this.finish(); } }, LOAD_DISPLAY_TIME); }}
load.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:gravity="center|center" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/load"> </LinearLayout>
3 创建主页面 MainActivity.java及相关布局文件main.xml
MainActivity.java
package com.timothy.load;import android.app.Activity;import android.os.Bundle;public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); }}
main.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" ><TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /></LinearLayout>
4 配置strings.xml
<?xml version="1.0" encoding="utf-8"?><resources> <string name="hello">Hello, this is a demo to picture before app start</string> <string name="app_name">LoadPictureDemo</string> <style name="MyTheme.NoTitleBar.CustomBackground" parent="@android:Theme.Black"> <item name="android:windowBackground">@drawable/load</item> <item name="android:windowNoTitle">true</item> <item name="android:windowFullscreen">true</item> <item name="android:windowContentOverlay">@null</item> </style></resources>
5 配置AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.timothy.load" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".LoadActivity" android:configChanges="orientation|keyboardHidden" android:theme="@style/MyTheme.NoTitleBar.CustomBackground"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MainActivity"> </activity> </application></manifest>
6 OK, 编译运行
启动过程中:
完成启动:
- Android启动过程中背景图片显示
- Android启动过程中背景图片显示
- Android启动过程中背景图片显示
- Android启动过程中背景图片显示
- Android启动过程中背景图片显示
- Android中GridView中Item点击背景图片的显示改变
- android系统开发小问题-启动过程中android字符没有显示出来
- Android系统开发小问题-启动过程中android字符没有显示出来 .
- 解决Android启动显示空白界面的问题,自定义进入软件前的背景图片。
- android中shape绘制背景图片
- 在android中添加背景图片
- android 项目中设置背景图片
- 关于android启动过程中logo
- Android中Activity启动过程探究
- Android中Activity启动过程探究
- Linux 中 Android的启动过程
- Android中Activity启动过程探究
- Android中Activity的简要启动过程
- FLEX读取带有xmlns定名空间的xml
- 组件
- ORDER BY ordinal position
- Android Manifest.permission 权限控制
- 云计算数据与信息安全防护
- Android启动过程中背景图片显示
- 关于C++中的内联函数(inline)
- vs2005配置库文件与头文件总结
- 存储过程中的when others then 和 raise 何意义?
- Postfix 学习 -- Linux添加/删除用户和用户组
- 内存使用技巧及内存池实现(二)
- Andriod: 去掉系统自带的Activity跳转动画,跳转无动画
- 正则表达式取HTTP链接
- 关于 ASINetworkQueues