Android Theme.AppCompat.Light.DarkActionBar不会显示任何操作栏

Android Theme.AppCompat.Light.DarkActionBar不会显示任何操作栏,android,android-studio,android-styles,Android,Android Studio,Android Styles,我在Android Studio中创建了一个带有空白活动的项目(然后编写代码,将其放入一个基本的片段-空线性布局),但没有显示ActionBar。为什么? 设备:仿真器(Nexus 5大小),API 19 主活动扩展了片段活动 Android Studio生成的styles.xml: <resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.A

我在Android Studio中创建了一个带有空白活动的项目(然后编写代码,将其放入一个基本的片段-空线性布局),但没有显示ActionBar。为什么?

设备:仿真器(Nexus 5大小),API 19

主活动扩展了
片段活动

Android Studio生成的styles.xml:

<resources>

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

</resources>

活动布局:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/fragmentContainer"
              android:layout_width="match_parent"
              android:layout_height="match_parent" />

片段:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent" />

舱单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mycompany.test" >

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

我需要主类来扩展
AppCompatActivity
,而不是扩展
FragmentActivity

如下文所述:

如果您使用的是v7 appcompat库,那么您的活动应该扩展ActionBarActivity,它是FragmentActivity的一个子类(有关更多信息,请阅读添加操作栏)

编辑


ActionBarActivity
。改为使用
AppCompatActivity

@Elltz我添加了清单。我从ActionBarActivity扩展了我的活动,并使用了“Theme.AppCompat.Light”,但现在它不会在操作栏上显示应用图标,只显示活动的名称。如果我使用“ThemeOverlay.AppCompat”并扩展“Activity”,它会显示带有应用图标的操作栏,但我不喜欢这个主题,因为我看不到黑色文本。