首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >操作栏为‘’灰色‘’/invisible颜色

操作栏为‘’灰色‘’/invisible颜色
EN

Stack Overflow用户
提问于 2017-07-04 10:48:25
回答 1查看 614关注 0票数 0

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

代码语言:javascript
复制
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);

}

这是我的风格,清单使用了下面的FMSTheme:

代码语言:javascript
复制
<!-- 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>

Invisible actionbar image

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-04 11:20:45

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

代码语言:javascript
复制
public class MapsActivity extends AppCompatActivity {

一旦你这样做了,我建议你将一个工具栏设置为一个actionbar:

代码语言:javascript
复制
Toolbar toolbar = (Toolbar) findViewById(R.id.maps_activity_toolbar);
toolbar.setTitle("A title");
setSupportActionBar(toolbar);

然后,您可以使用以下两个属性配置工具栏的主题:

代码语言:javascript
复制
<android.support.v7.widget.Toolbar
    android:theme="@style/MyToolbarTheme"
    app:popupTheme="@style/MyToolbarPopupTheme">

你可以根据自己的意愿进行定制,例如,你可以有一个深色的动作栏主题和一个浅色菜单主题(反之亦然):

代码语言:javascript
复制
<!-- the theme of the toolbar on MapsActivity -->
<style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    <!-- Customize your theme here. -->
    <!-- default text color and menu dots -->
    <item name="android:textColorPrimary">@color/my_toolbar_text_color</item>
</style>

<!-- the theme of the menu which opens from ActionBar on MapsActivity -->
<style name="MyToolbarPopupTheme" parent="ThemeOverlay.AppCompat.Light">
    <!-- Customize your theme here. -->
</style>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44896246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档