Android - Action Bar未显示使用Theme.AppCompat

Mod*_*ody 8 android android-theme android-actionbar

我正在尝试使用Theme.AppCompat,但是当我做动作栏时,它就会消失.没有错误或任何错误.

问题是我在另外两个项目上使用了这个确切的设置,它们工作正常,不确定发生了什么变化.

我还尝试更改支持库版本,父主题,清理项目,重建和使缓存无效.不知道是否有任何帮助,但无论如何我都做了.

我使用的是Android Studio 0.8.14

如果我错了,请纠正我,但这就是我在旧API上使用Material Theme小部件和调色板的方式,对吧?

预习

在此输入图像描述


styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

</resources>
Run Code Online (Sandbox Code Playgroud)

AndroidManifest.xml中

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".ActivityLogin"
        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>
Run Code Online (Sandbox Code Playgroud)

的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.2'
}
Run Code Online (Sandbox Code Playgroud)

小智 18

我的回答应该是评论,但这是我能回复的唯一方法.您是否在活动中扩展了ActionBarActivity?你在活动中尝试过show()方法吗?