android启动画面
来源:互联网 发布:淘宝怎么打不开了 编辑:程序博客网 时间:2024/04/30 21:20
在应用程序中经常用到启动画面,会启动一个后台线程为主程序的运行准备资源。
Android要实现启动画面可以这样做:
这是splash.xml布局文件的代码
代码
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical">
<ImageView android:layout_height="fill_parent" android:layout_width="fill_parent" android:scaleType="fitCenter" android:src="@drawable/splash"></ImageView>
</LinearLayout>
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical">
<ImageView android:layout_height="fill_parent" android:layout_width="fill_parent" android:scaleType="fitCenter" android:src="@drawable/splash"></ImageView>
</LinearLayout>
放一个ImageView加载启动画面图片
SplashActivity作为主视图启动
代码
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Handler x = new Handler();
x.postDelayed(new splashhandler(), 2000);
}
class splashhandler implements Runnable{
public void run() {
startActivity(new Intent(getApplication(),MainActivity.class));
SplashActivity.this.finish();
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Handler x = new Handler();
x.postDelayed(new splashhandler(), 2000);
}
class splashhandler implements Runnable{
public void run() {
startActivity(new Intent(getApplication(),MainActivity.class));
SplashActivity.this.finish();
}
}
加载后使用Handler的postDelayed方法,2秒后执行跳转到主视图。
- Android启动画面实现
- Android启动画面Splash
- Android启动画面Splash
- android程序启动画面
- Android启动画面
- Android创建启动画面
- android启动画面
- Android创建启动画面
- Android创建启动画面
- Android启动画面实现
- android启动画面
- Android创建启动画面
- Android启动画面
- Android启动画面实现
- Android实现启动画面
- Android启动画面实现
- Android创建启动画面
- android启动画面
- GameProtectNet导致电脑蓝屏的尝试解决方案
- 一个成功的git分支模型
- leveldb研究2- 存储分析,数据库日志文件格式,数据文件的格式和生成
- 准备在AIX上安装或升级到Oracle 11.2.0.3的注意事项
- tasklet的使用与理解
- android启动画面
- C++遍历文件夹,使用boost filesystem递归遍历文件夹
- leveldb研究5- Snapshot, Level和Compaction
- 在RealTouch中实现一个计算器
- Korsaraju算法 强连通分量
- leveldb研究7-Version/VersionSet/VersionEdit,内存中的数据结构Memtable/SkipList
- 数据结构---->图的遍历
- MPI Message Passing Interface
- Boost.Filesystem