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

ydn*_*nas 0 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"/>
Run Code Online (Sandbox Code Playgroud)

我的代码是:

    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);
Run Code Online (Sandbox Code Playgroud)

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

Com*_*are 5

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

或者:

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

  • android:targetSdkVersion是11岁以下,在这种情况下,提高它

请参阅:与菜单按钮说再见.