惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security @ Cisco Blogs
Y
Y Combinator Blog
N
Netflix TechBlog - Medium
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
C
Check Point Blog
爱范儿
爱范儿
A
About on SuperTechFans
博客园 - 聂微东
V
Visual Studio Blog
博客园_首页
WordPress大学
WordPress大学
Help Net Security
Help Net Security
博客园 - Franky
Forbes - Security
Forbes - Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Webroot Blog
Webroot Blog
博客园 - 司徒正美
人人都是产品经理
人人都是产品经理
量子位
Vercel News
Vercel News
Google DeepMind News
Google DeepMind News
W
WeLiveSecurity
V
V2EX
SecWiki News
SecWiki News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hugging Face - Blog
Hugging Face - Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Securelist
L
LangChain Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Schneier on Security
Schneier on Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
The Register - Security
The Register - Security
L
Lohrmann on Cybersecurity
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Cyber Attacks, Cyber Crime and Cyber Security
Simon Willison's Weblog
Simon Willison's Weblog
Apple Machine Learning Research
Apple Machine Learning Research
Security Archives - TechRepublic
Security Archives - TechRepublic
Latest news
Latest news
Spread Privacy
Spread Privacy
F
Full Disclosure
美团技术团队
I
Intezer

博客园 - 两耳不闻窗外事、一心只做程序员

转发 关于Windows安装解压版MySQL出现服务正在启动-服务无法启动的问题 CentOS 安装 jdk1.8 转:MyBatis 日志打印 转:APP开发浅谈-Fiddler抓包详解 C#中用DateTime的ParseExact方法解析日期时间(excel中使用系统默认的日期格式) java程序中的乱码方案 转: 解决Setting property 'source' to 'org.eclipse.jst.jee.server的问题 转:Eclipse中web项目部署至Tomcat步骤 google chrome 浏览器去掉 XHR finished loading.... [转]AJAX POST请求中参数以form data和request payload形式在servlet中的获取方式 SpringMVC Controller接收前台ajax的GET或POST请求返回各种参数 下载Tomcat时Tomcat网站上的core和deployer的区别 vmware 修改IP 提示子网掩码错误~ android ImageView 中的ScaleType vs文件属性(生成操作)各选项功能(发布Web项目时使用) 导入 RecyclerView 控件 的过程(Android 6.0) Android RelativeLayout用到的一些重要的属性 Andriod中textview垂直水平居中及LinearLayout内组件的垂直布局 使用VS2013逆向生成UML类图
requestWindowFeature(Window.FEATURE_NO_TITLE)无效解决方法
两耳不闻窗外事、一心只做程序员 · 2016-08-16 · via 博客园 - 两耳不闻窗外事、一心只做程序员

今天在《第一行代码》上学习做自定义标题栏,需要将系统自带的标题栏隐藏掉,使用自定义的标题栏,结果发现,requestWindowFeature(Window.FEATURE_NO_TITLE); 这句代码无效,标题栏无法隐藏,可我以前都可以隐藏啊,今天怎么不可以了,最终发现是Activity的继承问题,我的代码是这样的

public class TitlebarActivity extends AppCompatActivity

可以看出我的Activity是继承自AppCompatActivity,所以requestWindowFeature(Window.FEATURE_NO_TITLE);这句失效了。

解决方法有两种

  1. 将AppCompatActivity改为Activity,此时 requestWindowFeature(Window.FEATURE_NO_TITLE);是有效的
  2. 在onCreate()方法中加入如下代码:
if (getSupportActionBar() != null){
   getSupportActionBar().hide();
}

现在就可以隐藏标题栏了。