Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5933609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:59:49+00:00 2026-05-22T14:59:49+00:00

I have the following Android menu XML file: <?xml version=1.0 encoding=utf-8?> <menu xmlns:android=http://schemas.android.com/apk/res/android> <item

  • 0

I have the following Android menu XML file:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/programma"
          android:icon="@android:drawable/ic_menu_agenda"
          android:title="@string/programma" />
    <item android:id="@+id/settings"
          android:icon="@android:drawable/ic_menu_preferences"
          android:title="@string/settings" />
    <item android:id="@+id/help"
          android:icon="@android:drawable/ic_menu_help"
          android:title="@string/help" />
</menu>

That gives me three menu buttons on one line. However, I want to divide them in two lines, with 2 buttons on the first row, and the help button on the entire bottom row. I already tried grouping the first two, but that didn’t do the trick.
How can I force a line break in the XML?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:59:50+00:00Added an answer on May 22, 2026 at 2:59 pm

    As far as I know there is no way to force line break in menu. This actually makes sense if you consider some scenarios.

    For example, imagine you have tablet (for example, Galaxy Tab) in landscape orientation. It has quite a lot of horizontal space and relatively small height. So, it would be a waste of space if you force line break in such case.

    enter image description here


    I’ve done more investigation on this. There is a class called MenuBuilder which is used to manage options menu. It uses icon_menu_layout layout resource to draw menus. Here is this resource:

    <com.android.internal.view.menu.IconMenuView
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:id="@+android:id/icon_menu"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:rowHeight="66dip"
       android:maxItems="6"
       android:maxRows="2"
       android:maxItemsPerRow="6" />
    

    And if you follow to IconMenuView implementation, you’ll find one interesting function called layoutItems which is used to calculate layout for menu items. You can only influence this function’s logic by artificially increasing width of menu items. No line breaks are available.

    private void layoutItems(int width) {
        int numItems = getChildCount();
        if (numItems == 0) {
            mLayoutNumRows = 0;
            return;
        }
    
        // Start with the least possible number of rows
        int curNumRows =
                Math.min((int) Math.ceil(numItems / (float) mMaxItemsPerRow), mMaxRows);
    
        /*
         * Increase the number of rows until we find a configuration that fits
         * all of the items' titles. Worst case, we use mMaxRows.
         */
        for (; curNumRows <= mMaxRows; curNumRows++) {
            layoutItemsUsingGravity(curNumRows, numItems);
    
            if (curNumRows >= numItems) {
                // Can't have more rows than items
                break;
            }
    
            if (doItemsFit()) {
                // All the items fit, so this is a good configuration
                break;
            }
        }
    }
    

    So, for example, if you increase width of first item, you’ll get two lines in menu. But this is probably undesirable, because you can’t predict text style, size and font that will be used on different devices.

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XML layout for a ListActivity. <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
My select_screen_menu.xml <?xml version=1.0 encoding=utf-8?> <menu xmlns:android=http://schemas.android.com/apk/res/android> <item android:id=@+id/home_menu android:icon=@drawable/home_tab android:title=Home /> <item android:id=@+id/submit_report
I have the following menu layout in my Android app: <?xml version=1.0 encoding=utf-8?> <menu
I have the following TextView in my XML layout file:- <TextView android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/autolink_test
I have the following XML layout in my android application, using ScrollView: <?xml version=1.0
I am following this tutorial https://developer.android.com/guide/tutorials/views/hello-tabwidget.html and have completed it. Now I would actually
Hello i have the following xml for menu i want to set the background
I have the following activity... package org.dewsworld; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import
I have the following code for Android which works fine to play a sound
I have the following code running on my Android device. It works great and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.