去掉标题栏/ActionBar后点击menu键时应用崩溃
MainActivity 继承了 ActionBarActivity后,想要去掉标题栏(ActionBar),在程序中加上requestWindowFeature(Window.FEATURE_NO_TITLE);,结果标题栏是去掉了,但是在点击Menu键时应用会崩溃。在网上找了一下解决方法,都是把MainActivity继承ActionBarActivity改为继承Activity,这样虽然能够解决问题,但是如果一定是要继承ActionBarActivity不能改的话要怎么办呢?例如在我的程序里,需要调用getSupportFragmentManager(),如果MainActivity继承Activity的话我就没办法调用此函数。
解决办法:去掉requestWindowFeature(Window.FEATURE_NO_TITLE);这一句,改为下面两句:
ActionBar actionBar=getSupportActionBar();
actionBar.hide();
附:Android系统自带样式
在xml文件中进行配置
在项目的清单文件AndroidManifest.xml中,找到需要全屏或设置成无标题栏的Activity,在该Activity进行如下配置即可。
android:theme="@android:style/Theme.Dialog" 将一个Activity显示为能话框模式
android:theme="@android:style/Theme.NoTitleBar" 不显示应用程序标题栏
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不显示应用程序标题栏,并全屏
android:theme="Theme.Light" 背景为白色
android:theme="Theme.Light.NoTitleBar" 白色背景并无标题栏
android:theme="Theme.Light.NoTitleBar.Fullscreen" 白色背景,无标题栏,全屏
android:theme="Theme.Black" 背景黑色
android:theme="Theme.Black.NoTitleBar" 黑色背景并无标题栏
android:theme="Theme.Black.NoTitleBar.Fullscreen" 黑色背景,无标题栏,全屏
android:theme="Theme.Wallpaper" 用系统桌面为应用程序背景
android:theme="Theme.Wallpaper.NoTitleBar" 用系统桌面为应用程序背景,且无标题栏
android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" 用系统桌面为应用程序背景,无标题栏,全屏
android:theme="Translucent" 透明背景
android:theme="Theme.Translucent.NoTitleBar" 透明背景并无标题
android:theme="Theme.Translucent.NoTitleBar.Fullscreen" 透明背景并无标题,全屏
android:theme="Theme.Panel" 面板风格显示
android:theme="Theme.Light.Panel" 平板风格显示
最新文章
- CSS选 择器 三种样式
- 一个经典实用的iptables shell脚本
- Web程序的桌面提醒
- QGridLayout--01
- eclipse lua使用
- Linux设备模型 学习总结
- SaaS应用“正益工作”发布,为大中型企业轻松构建移动门户
- 如何导入hadoop源码到eclipse
- new的原理
- python RabbitMQ队列使用(入门篇)
- JS 拖动DIV 需要JQUERY 支持
- Java禁止浏览器有缓存的源码
- 关于input的一些问题解决方法分享
- windows组策略实验-本地组策略和域控组策略
- MongDB 数据结构
- Day17总结
- webservice 客户端调用
- [转帖]SAP MES生产执行系统解决方案
- SpringBoot自定义HttpMessageConverter
- 什么是SQL注入式攻击和如何防范?
热门文章
- axios 设置超时时间 timeout
- jenkins调用shell脚本 输出带颜色字体
- php 记录图片浏览次数次数
- Android应用程序开发以及背后的设计思想深度剖析
- UVa 437 The Tower of Babylon(DP 最长条件子序列)
- different between method and function
- 近期建了一个.net源代码共享群,群共享有大量网友分享的.net(C#)商业源代码
- sparkstreaming+socket workCount 小案例
- Google Code Jam 2014 Round 1 A:Problem A Charging Chaos
- mysql单表导入数据,全量备份导入单表