自定义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



网上说,去掉AndroidManifest.xmlActivity的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文件


4.0 即API 14,AppBaseTheme应该在values-v14/style.xml里面的


于是我再去看android:Theme.Holo.Light.DarkActionBar


<style name="Theme.Holo.Light.DarkActionBar">里面没有关于类似<style name="windowNoTitle">的东西


<style name="Theme.Holo.Light">代码


太多东西了{:soso_e117:},他们引用的东西也不尽相同.....


解决方法:

后来,我直接在AndroidManifest.xml中,将android:theme="@style/AppTheme"直接改成android:theme="@style/android:Theme.Light"(就是不继承API 14中的Theme,用回API 11前的Theme)

或者,删除values-v11values-v14里面的styles.xml


让系统自动调用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>

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

更多相关文章

  1. Android(安卓)Lifecycle
  2. Android(安卓)Studio发布项目到jcenter,一行代码引入Module
  3. 第一行代码-5.4 使用本地广播
  4. android的aidl进程间通讯(二)
  5. android webview js
  6. Ubuntu 10.04(64位)下载并编译 Android(安卓)2.2 源码[只有11条命
  7. Android系统默认Home应用程序(Launcher)的启动过程源代码分析(2)
  8. Demo_ ZoomActivity 解读
  9. android如何取得本地通讯录的头像的原图的实现代码

随机推荐

  1. Android手机重启的核心代码
  2. 相对布局(RelativeLayout)
  3. 怎么访问android 网站
  4. AndroidStudio学习(二)-模拟小相册
  5. android中的wife
  6. 设置Textview最大长度,超出显示省略号
  7. Android(安卓)studio报错Could not GET
  8. RelativeLayout相关属性
  9. 【Android】编译CM10.1遇到的错误解决方
  10. android SDK dl fetched