【问题标题】:Removing the title bar make the entire app background look black去掉标题栏让整个app背景变黑
【发布时间】:2013-10-31 05:23:27
【问题描述】:

我需要从我的整个应用程序中删除ActionBar,所以我在清单中的代码中添加了Theme.NoTitleBar

以下是我的清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.beleeta.bileetacrm"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar" >
        <activity
            android:name="com.beleeta.bileetacrm.Home"
            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>

</manifest>

但是,这会使整个应用程序的背景看起来是黑色的!在我做这个更改之前,应用程序是白色的,下面是代码

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.beleeta.bileetacrm"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.beleeta.bileetacrm.Home"
            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>

</manifest>

为什么会这样?我怎样才能摆脱这个?这是我第一次处理这些操作栏。

我的最小 SDK 是 11。

【问题讨论】:

    标签: java android eclipse android-actionbar android-titlebar


    【解决方案1】:

    默认的 Theme(因此,Theme.NoTitleBar)是深色主题 - 您可以将 Theme.Light.NoTitleBar 用于浅色(即背景)主题。

    【讨论】:

    • 简单明了!这样代码中没有笨拙的东西......这应该成为公认的答案。
    【解决方案2】:

    从清单文件中删除 android:theme="@android:style/Theme.NoTitleBar"。并添加这个

    this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    

    在你做 setcontentview 之前的每一堂课。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-15
      • 2012-09-08
      • 2021-11-03
      • 2019-10-14
      • 1970-01-01
      • 1970-01-01
      • 2018-10-05
      • 1970-01-01
      相关资源
      最近更新 更多