Android动态加载启动页
来源:互联网 发布:手机数据流量无法上网 编辑:程序博客网 时间:2024/06/08 10:33
public class MainActivity extends Activity {private Dialog splashDialog;@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //1.创建 Display display = this.getWindowManager().getDefaultDisplay(); Dialog dialog = new Dialog(this); LinearLayout root = new LinearLayout(this); root.setMinimumHeight(display.getHeight()); root.setMinimumWidth(display.getWidth()); root.setOrientation(LinearLayout.VERTICAL); root.setBackgroundColor(Color.BLACK); root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 方式一: root.setBackgroundResource(R.drawable.ic_launcher); 方式二: ImageView img = new ImageView(context); img.setImageBitmap(bitmap); root.addView(img); // Create and show the dialog splashDialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar); // check to see if the splash screen should be full screen if ((this.getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) { splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } splashDialog.setContentView(root); splashDialog.setCancelable(false); //计时3秒后显示 CountDownTimer timer = new CountDownTimer(2 * 1000, 1000) { @Override public void onTick(long millisUntilFinished) { } @Override public void onFinish() { splashDialog.show(); } }; timer.start();}}
2.关闭销毁
if (splashDialog != null && splashDialog.isShowing()) { splashDialog.dismiss(); splashDialog = null; }
0 0
- Android动态加载启动页
- Android-->动态加载Activity (不使用Intent,启动Activity)
- iOS启动页加载静态图和动态图
- Android动态加载(五)--动态加载框架
- Android 动态加载布局
- android 加载动态库
- Android 动态加载布局
- Android 动态加载布局
- android 动态加载Listview
- android ListView 动态加载
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android动态加载TabHost
- Android 动态加载menu
- Android app动态加载
- Android热修复---AndFix
- React学习总结(1)——开始
- Tomcat日志catalina.out分割
- ZTree学习(二):异步加载树结构
- iOS 为什么选择了OC
- Android动态加载启动页
- Android产品研发(二十)-->代码Review
- UVa 1025 A Spy in the Metro
- 【Android 动画专题】
- DevExpress GridControl复合表头(多行表头)设置
- 调用kettle api传参时不赋值的解决方法
- Java static关键字以及Java静态变量和静态方法
- CentOS6.8下Hadoop2.7.2怎么运行自带的wordcount程序
- 文章标题