requestWindowFeature()隐藏标题栏无效
来源:互联网 发布:视频剪切软件绿色版 编辑:程序博客网 时间:2024/06/05 07:18
requestWindowFeature(Window.FEATURE_NO_TITLE); 隐藏标题栏,该语句需要在setContentView()方法前被执行,但是在测试时,发现该功能没有起作用。
代码如下:
public class FirstActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_first); } //省略部分代码...... }
之后修改FirstActivity的继承类,由 ActionBarActivity 修改为 Activity ,该代码就起作用了。
为什么会这样呢?
查找ActionBarActivity的API 及 ActionBar的API,是这样讲的
ActionBarActivity :
ActionBar:
由于ActionBar是在API 11之后才有的,因此ActionBarActivity 是为API 7 及更高版本提供ActionBar的实现。
如果想实现标题栏隐藏,可以把requestWindowFeature(Window.FEATURE_NO_TITLE);放在调用super.onCreate()之前或者使用getSupportActionBar().hide();方法,代码参考如下:
public class FirstActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_first); } //省略部分代码...... }
或者
public class FirstActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { //requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); getSupportActionBar().hide(); setContentView(R.layout.activity_first); } //省略部分代码...... }
0 0
- requestWindowFeature()隐藏标题栏无效
- requestWindowFeature()隐藏标题栏无效
- android 隐藏标题栏 无效 requestWindowFeature(Window.FEATURE_NO_TITLE)
- As的 requestWindowFeature(Window.FEATURE_NO_TITLE)标题栏隐藏无效问题
- requestWindowFeature无法隐藏标题栏
- 隐藏标题栏之二 requestWindowFeature
- 解决requestWindowFeature(Window.FEATURE_NO_TITLE);无法隐藏标题栏
- 【仅收藏】隐藏ActionBar:requestWindowFeature(Window.FEATURE_NO_TITLE)无效解决方法
- requestWindowFeature(标题栏)
- requestWindowFeature(标题栏)
- android studio 中去除actionbar 标题栏的方法。requestWindowFeature(Window.FEATURE_NO_TITLE)无效
- Android 中无法取消标题栏的问题,requestWindowFeature(Window.FEATURE_NO_TITLE);无效
- android5.0使用requestWindowFeature(Window.FEATURE_NO_TITLE)隐藏标题栏的报错的解决方法
- android studio中requestWindowFeature(Window.FEATURE_NO_TITLE)隐藏标题栏失效的解决方案
- android studio中requestWindowFeature(Window.FEATURE_NO_TITLE)隐藏标题栏失效的解决方案
- android studio中requestWindowFeature(Window.FEATURE_NO_TITLE)隐藏标题栏失效的解决方案
- requestWindowFeature(Window.FEATURE_NO_TITLE)无效
- requestWindowFeature(Window.FEATURE_NO_TITLE);无效
- Sicily 1629. Area of Polycubes
- 希尔排序
- 学习笔记3/13
- c#面向对象(二)----命名空间
- Sicily 1627. Text Messaging Improvement?
- requestWindowFeature()隐藏标题栏无效
- Sicily 1528. Spatial Concepts Test
- #iOS# 沙盒目录获取
- Sicily 1514. Flipping Burned Pancakes
- 辛苦了那么久,终于HI3516A开发板要贴片出来咯
- Sicily 1207. No Fold
- (cocos2dx学习日记二)中文乱码。添加精灵。添加菜单。添加动画。
- Sicily 1955/2612. Fort
- NOIP2002 均分纸牌