Android 操作栏位于'';灰色/看不见的颜色

Android 操作栏位于'';灰色/看不见的颜色,android,android-actionbar,Android,Android Actionbar,我正在尝试为我的活动创建一个选项菜单。 首先,它没有显示,我按照说明添加了requestWindowFeature(Window.FEATURE\u ACTION\u栏);在onCreate方法中,操作栏显示,但颜色为“灰色”/“不可见”。我仍然可以点击菜单项。你能告诉我如何使动作栏可见吗?谢谢 这是我的活动,是扩展FragmentActivity,这是必须的,因为我的地图片段需要它: public class MapsActivity extends FragmentActivity{ @O

我正在尝试为我的活动创建一个选项菜单。 首先,它没有显示,我按照说明添加了requestWindowFeature(Window.FEATURE\u ACTION\u栏);在onCreate方法中,操作栏显示,但颜色为“灰色”/“不可见”。我仍然可以点击菜单项。你能告诉我如何使动作栏可见吗?谢谢 这是我的活动,是扩展FragmentActivity,这是必须的,因为我的地图片段需要它:

public class MapsActivity extends FragmentActivity{
 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    setContentView(R.layout.activity_map);
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
<!-- FMS theme -->
<style name="FMSTheme" parent="AppBaseTheme">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowActionModeOverlay">false</item>
</style>
}

<!-- FMS theme -->
<style name="FMSTheme" parent="AppBaseTheme">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowActionModeOverlay">false</item>
</style>
这是我的风格,清单使用了以下主题:

<!-- FMS theme -->
<style name="FMSTheme" parent="AppBaseTheme">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowActionModeOverlay">false</item>
</style>

<!-- FMS theme -->
<style name="FMSTheme" parent="AppBaseTheme">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowActionModeOverlay">false</item>
</style>

假的
假的
假的

让您的MapsActivity扩展AppCompatActivity(来自支持库),它本身扩展了FragmentActivity:

<!-- FMS theme -->
<style name="FMSTheme" parent="AppBaseTheme">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowActionModeOverlay">false</item>
</style>
public class MapsActivity extends AppCompatActivity {
完成后,我建议将工具栏设置为actionbar:

<!-- FMS theme -->
<style name="FMSTheme" parent="AppBaseTheme">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowActionModeOverlay">false</item>
</style>
Toolbar toolbar = (Toolbar) findViewById(R.id.maps_activity_toolbar);
toolbar.setTitle("A title");
setSupportActionBar(toolbar);
然后,您可以使用以下两个属性配置工具栏的主题:

<!-- FMS theme -->
<style name="FMSTheme" parent="AppBaseTheme">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowActionModeOverlay">false</item>
</style>
<android.support.v7.widget.Toolbar
    android:theme="@style/MyToolbarTheme"
    app:popupTheme="@style/MyToolbarPopupTheme">

您可以根据自己的意愿定制,例如,您可以有一个暗操作栏主题和一个亮菜单主题(或反之亦然):

<!-- FMS theme -->
<style name="FMSTheme" parent="AppBaseTheme">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowActionModeOverlay">false</item>
</style>

@颜色/我的工具栏\u文本\u颜色

什么是colorPrimary和colorPrimaryDark?非常感谢Alessio,将extends更改为AppCompatActivity工作,菜单栏现在可见。非常感谢工具栏的定制……非常欢迎@M.N,工具栏是您的朋友,它是一个功能强大的工具,比ActionBar更灵活:)