博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android App 隐藏标题栏+状态栏+导航栏
阅读量:7220 次
发布时间:2019-06-29

本文共 1771 字,大约阅读时间需要 5 分钟。

1. 隐藏当前Activity标题栏

    在当前Activity中调用:this.requestWindowFeature(Window.FEATURE_NO_TITLE);

2. 隐藏当前Activity状态栏(Status Bar)

2.1 Android 4.0 and Lower

public class MainActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        // If the Android version is lower than Jellybean, use this call to hide        // the status bar.        if (Build.VERSION.SDK_INT < 16) {            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,                    WindowManager.LayoutParams.FLAG_FULLSCREEN);        }        setContentView(R.layout.activity_main);    }    ...}

2.2 Android 4.1 and Higher

View decorView = getWindow().getDecorView();// Hide the status bar.int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;decorView.setSystemUiVisibility(uiOptions);// Remember that you should never show the action bar if the// status bar is hidden, so hide that too if necessary.ActionBar actionBar = getActionBar();actionBar.hide();

3. 隐藏当前Activity界面的导航栏(NavigationBar)

    在Android4.0及以后版本号中。可通过下面方法隐藏NavigationBar

View decorView = getWindow().getDecorView();// Hide both the navigation bar and the status bar.// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as// a general rule, you should design your app to hide the status bar whenever you// hide the navigation bar.int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION              | View.SYSTEM_UI_FLAG_FULLSCREEN;decorView.setSystemUiVisibility(uiOptions);

4. 隐藏全部Activity界面的标题栏

 改动AndroidManifest.xml 
 在application 标签中加入a
    android:theme="@android:style/Theme.NoTitleBar"

5. 隐藏全部Activity界面的TitleBar 和StatusBar 

  改动AndroidManifest.xml 
  在application 标签中加入 

  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

转载地址:http://mdhym.baihongyu.com/

你可能感兴趣的文章
zabbix用户管理(9)
查看>>
MySQL数据库用户授权管理
查看>>
使用冒泡排序,排序多个字符串
查看>>
Huffman编码
查看>>
windows DHCP 服务器迁移技术文档
查看>>
Hql语句使用
查看>>
Spring2.5学习笔记2-AOP-利用通知接口
查看>>
不想转型高升?12条箴言助IT人士提高效率
查看>>
HP BL660 GEN8 SUSE 11 查询HBA信息 驱动版本 固件版本 设备名称
查看>>
幕夜萧萧,梦邀十月迷情
查看>>
Linux 系统自动化安装
查看>>
java中类的加载,及执行顺序
查看>>
apache配置虚拟主机及虚拟目录
查看>>
经典问题解析三(三十)
查看>>
Android 上下文菜单
查看>>
Nginx实战基础篇四 通过https方式访问web服务器
查看>>
菜鸟篇-简单HttpClient
查看>>
MySQL中索引的限制
查看>>
数据库中DDL和DML说明
查看>>
我的友情链接
查看>>