android自定义标题栏时候you cannot combine custom titles with other title

来源:互联网 发布:淘宝网多肉植物 编辑:程序博客网 时间:2024/05/19 23:58

在添加自定义的标题栏时,报错,you cannot combine custom titles with other titles...


AndroidManifest.xml中:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.umosleep"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/mystyle" >

<activity
            android:name="com.umosleep.activity.MainTabActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Light.NoTitleBar" >
             <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            
            
        </activity>

</application>

</manifest>


mystyle.xml:

<resources>

<style name="CustomWindowTitleBackground">
       <item name="android:background">#5baffd</item>
</style>

<style name="mystyle" parent="android:Theme">
     <item name="android:windowTitleSize">50dp</item>
     <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>

</resources>


Mainactivity.java:

onCreate()函数调用:
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.activity_bind);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar_bind);



解决办法
在manifest文件中,修改Activity下的android:theme="@style/android:Theme.Light" 
这样便能正常运行了

0 0
原创粉丝点击