zoukankan      html  css  js  c++  java
  • 安卓启动图去除顶部title和状态栏

    1.在启动页的xml配置中,设置layout的id,

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/back"
        android:id="@+id/img_lay"
        tools:context="com.zhou.myapplication.LaunchImgActivity">
    </LinearLayout>

    2.在启动的activity类中加入如下代码:

    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.launch_img);
            //去除状态栏
            LinearLayout linearLayout =(LinearLayout)findViewById(R.id.img_lay);
            linearLayout.setSystemUiVisibility(View.INVISIBLE);  //设置不可见
            //延迟加载主页面
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    Intent intent = new Intent(LaunchImgActivity.this, MainActivity.class);
                    LaunchImgActivity.this.startActivity(intent);
                    LaunchImgActivity.this.finish();
    
                }
            }, 2000);
        }

    3.在style.xml中修改成如下代码,主要是把parent改为NoActionBar:

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
            <!-- Customize your theme here. -->
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
            <!-- 沉浸式状态栏 -->
            <item name="android:fitsSystemWindows">true</item>
            <item name="android:clipToPadding">false</item>
        </style>

    运行之后可以看到启动图全屏展示。

  • 相关阅读:
    06 继承与多态
    动手动脑 4 String 类
    字串加密
    课后作业(查询类对象创建个数)
    动手动脑 3 类与对象
    动手动脑 (第二次)
    IOS 网络判断
    ios常用的几个动画代码
    iOS Get方式带中文不能请求网络
    UILabel Text 加下划线
  • 原文地址:https://www.cnblogs.com/phpzhou/p/9024388.html
Copyright © 2011-2022 走看看