需要在Action Bar Android中隐藏菜单按钮

时间:2014-02-13 13:06:56

标签: android android-layout android-actionbar

我正在尝试在android中自定义我的操作栏。我创建了一个这样的自定义布局:

<TextView 
    android:id="@+id/actionBarTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Sample"/>    
<ImageView 
    android:id="@+id/actionBarImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/some_image"/>

我的代码是:

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

    // Do any other config to the action bar
    getActionBar().setDisplayShowTitleEnabled(false);
    getActionBar().setDisplayShowHomeEnabled(false);
    getActionBar().setDisplayHomeAsUpEnabled(false);
    getActionBar().setCustomView(R.layout.custom_action_bar_layout);

我可以在操作栏中看到我的自定义布局,但随后我会在操作栏的最右侧看到菜单图标。我不知道如何删除或隐藏它。请帮助我。

1 个答案:

答案 0 :(得分:5)

  

我在操作栏的最右侧显示菜单图标

或者:

  • 您已定义要在溢出区域中显示的项目,在这种情况下,请删除这些项目,或

  • android:targetSdkVersion未满11岁,在这种情况下,提高

请参阅:Say Goodbye to the Menu Button

相关问题