Skip to content Skip to sidebar Skip to footer

How Can I Override My Menu Bar To Come On My Application Bar?

I have recycler view + viewpager + toolbar in my activity. When I long click on the row in recycler view it should show me a menu bar with a delete option. But this is what I get.

Solution 1:

Issue for About button:

<item
    android:id="@+id/menu_item_about"
    android:title="@string/menu_about"
    app:showAsAction="never"  />

update the never part to "ifRoom"

Regarding the menu appearing, can you be more explicit, as to me it seems in Relative Layout you wanted the Toolbar to be top and the views to come after it and that is what it shows.

Solution 2:

So I have solved one of the problems. This is what I edited in my code to display add and about buttons in the toolbar.

First, in your onCreate in the fragments, add this line:

setHasOptionsMenu(true);

Second, in your styles, change your theme to something which has NoActionBar. In my case I did this:

<stylename="AppThemeOfStyles"parent="Theme.AppCompat.Light.NoActionBar"><itemname="colorPrimary">#FF595951</item><itemname="colorPrimaryDark">#FF5C5C5C</item><itemname="colorAccent">#FFCCCCCC</item><itemname="android:textColorPrimary">#FF0FF0</item><itemname="windowActionBar">true</item><itemname="windowNoTitle">true</item></style>

I also changed the name of my theme from AppTheme to AppTheme of styles since AppTheme is already a theme defined. So better to change your theme name to something else.

This leads us to the result below: enter image description here

But my delete is still coming on the top of the toolbar on longpress.

enter image description here Any suggestions, advice will be appreciated :)

UPDATED: Use this in your theme for the overlay to work: <item name="windowActionModeOverlay">true</item>

Here is the end result: enter image description here

Post a Comment for "How Can I Override My Menu Bar To Come On My Application Bar?"