转 Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature

摘要:
010203040506070809101112131415˃@style/AppTheme可能设置了这个值?
自定义Titlebar时为了避免冲突

需要修改:AndroidManifest.xml

android:theme="@style/mystyle" 

styles.xml文件中需要加上下面内容

<style name="mystyle" parent="android:Theme">
<item name="android:windowTitleSize">50dp</item>
</style>
下面是网上别人的详细分析:
运行项目时,有时LogCat报错:AndroidRuntimeException: You cannot combine custom titles with other title feature
转 Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature第1张
网上说,去掉AndroidManifest.xml中Activity的android:theme="@android:style/Theme.NoTitleBar.Fullscreen"属性。但我看AndroidManifest.xml根本没有设这个值
[Java]纯文本查看复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/TitleBarStyle">
<activity
android:name="com.example.b.MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

有可能是@style/AppTheme里面设了这个值吧?于是我再看values/styles.xml文件
转 Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature第2张
4.0 即API 14,AppBaseTheme应该在values-v14/style.xml里面的
转 Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature第3张
于是我再去看android:Theme.Holo.Light.DarkActionBar
转 Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature第4张
<style name="Theme.Holo.Light.DarkActionBar">里面没有关于类似<style name="windowNoTitle">的东西
转 Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature第5张
<style name="Theme.Holo.Light">代码
转 Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature第6张
太多东西了{:soso_e117:},他们引用的东西也不尽相同.....
解决方法:
后来,我直接在AndroidManifest.xml中,将android:theme="@style/AppTheme"直接改成android:theme="@style/android:Theme.Light"(就是不继承API 14中的Theme,用回API 11前的Theme)
或者,删除values-v11和values-v14里面的styles.xml
转 Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature第7张
让系统自动调用values/styles.xml

由于API-11的<style name="Theme.Holo.Light">和API-14<style name="Theme.Holo.Light.DarkActionBar">跟API之前版本的<style name="Theme.Light">代码太多不同了,所以就我也不明白到底哪里出了问题

看到别人博客上还有一个解决的方案:

在style.xml中修改加入这句“<item name="android:windowActionBar">false</item>”

  1. <stylename="AppTheme"parent="AppBaseTheme">
  2. <!--AllcustomizationsthatareNOTspecifictoaparticularAPI-levelcangohere.-->
  3. <itemname="android:windowActionBar">false</item>
  4. </style>

免责声明:文章转载自《转 Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇STL --&amp;gt; stack栈通过response向服务器用Io流写入图片下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

安卓系统中各镜像介绍

背景 对于安卓开发而言,了解各镜像的意义、内容以及如何制作,有极大的意义。 注意,ROM中的5个镜像文件的扩展名都是img,但其格式却不同,也就是说不能使用同一种方法对其进行格式解析。 系统镜像(System.img) 系统镜像用于存储Android系统的核心文件,将其解压出来,就是设备中/system目录,里面包含了Android系统主要的目录和文件。一...

C# xml上传以及记录保存xml

1.xml保存 private readonly string XMLSavePath = Path.Combine(Environment.CurrentDirectory, "XML", GlobalParam.Today); public LogicalService(){// 创建XML日志保存目录if (!Directory.Exists(X...

检验多个xsd的xml是否合法

Java - 使用 XSD 校验 XML https://www.cnblogs.com/huey/p/4600817.html 这种方法不支持多个xsd文件,会报错 可以使用XMLBeans Tools来验证,3.1的版本用起来有问题,后来用2.6版本的就OK了 利用xmlbeans工具对xml格式进行验证(需要xsd文件) https://blog....

快速集成华为AGC云存储服务-Android

华为AppGallery Connect提供了一个云存储(CloudStorage)的服务,号称提供了一个便捷的云端存储服务,应用开发者使用的时候,可以不用关注服务器的部署,直接使用就行。 目前这个功能还在bate阶段,我先抢先体验了一下。如果你想快速体验云存储服务的功能,请参考demo。 1、环境与应用信息 版本名称 集成环境 测试设备 agco...

Android Demo练习体会

前言   由于昨天刚搭建好Android使用环境,非常想体验下Android开发过程,今天下班便在网上找了一些资料,根据资料DEMO做一个小程序来熟悉其开发过程。首先推荐一个网站http://www.inandroid.cn/bbs/forum-15-1.html。里面的内容对于初学还是不错的。为了开发方便API文档是不可少的,但是目前网上还没有中文的,所...

MyBatis开发--&amp;gt;接口方式编程

从本篇开始,引用借鉴博客:http://blog.csdn.net/techbirds_bao/article/details/9233599,里面是经典教程,但是有些纰漏。自己整理下,更加适合自己学习。 在前一篇入门篇我们使用的是SqlSession来执行查询语句: User user = session.selectOne("User.selectUs...