lawonga
lawonga

Reputation: 832

Android menu inflating in the wrong place

Here is my current problem:

My settings menu is inflating incorrectly. I have no idea why, and it is driving me nuts! Does anyone have a clue as to what is happening? The position of the menu should be slightly under the overflow icon. Is it perhaps the way I laid out my tabs or viewpagers, or is it something else? I'm sure this is not an isolated case, so if anyone has seen this problem before...

Thanks in advance!


In my MainActivity:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

In my menu_main.xml:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"
android:id="@+id/menu_item">
<item android:id="@+id/action_settings"
    android:title="@string/action_settings"
    android:orderInCategory="101"
    app:showAsAction="never" />
<item
    android:id="@+id/action_about"
    android:title="@string/action_about"
    android:orderInCategory="102"
    app:showAsAction="never"/>
</menu>

Upvotes: 1

Views: 549

Answers (1)

Rahul Tiwari
Rahul Tiwari

Reputation: 6968

this is default UI pattern and is not incorrect, refer following screenshot from official documentation: enter image description here

still if you don't like it, you can change this behaviour

refer this question for details.

Upvotes: 1

Related Questions