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 6961653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:33:30+00:00 2026-05-27T15:33:30+00:00

I’m dynamically generating a layout, and to do this I have a menu_row_element.xml file

  • 0

I’m dynamically generating a layout, and to do this I have a menu_row_element.xml file which contains the repeating row structure.

It consists of a LinearLayout (horizontal) which contains an image, a larger text above a smaller one, and an ImageView with a right arrow (inside another LinearLayout to keep it right aligned).

When the text part is small, everything looks fine. However if the text part is long, the right arrow is pushed off the screen.

How can I keep the right arrow always right aligned on the screen and have the textviews wrap the text appropriately?

In this image, the last row is OK since the text is small, but rows 1 and 2 push the right arrow off the screen.

a busy cat http://img706.imageshack.us/img706/2927/device20111221203115.jpg

The xml file is:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:clickable="true"
        android:background="@drawable/main_menu_button"
        android:paddingTop="5dp"
        android:paddingBottom="5dp"
        android:orientation="horizontal"
        android:gravity="left|center_vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <!-- Icon of each section -->
        <ImageView
            android:id="@+id/menu_icon"
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent"
            android:padding="10px" />

        <!-- Text, in two parts -->
        <LinearLayout
            android:orientation="vertical"
            android:paddingLeft="10px"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent">

            <!-- Big font text -->
            <TextView
                android:id="@+id/menu_element_big_text"
                android:textSize="20dp"
                android:textColor="@color/black"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

            <!-- Small font text -->
            <TextView
                android:id="@+id/menu_element_small_text"
                android:scrollHorizontally="false"
                android:textSize="15dp"
                android:textColor="@color/black"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>

        <!-- Layout just to be able to right align, sheesh! -->
        <LinearLayout
            android:gravity="right|center_vertical"
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:padding="0dp"
                android:src="@drawable/right" />
        </LinearLayout>

    </LinearLayout>

Thanks!

  • 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-27T15:33:31+00:00Added an answer on May 27, 2026 at 3:33 pm

    Use a RelativeLayout.

    The structure should be then:

    <LinearLayout> <!--This is the outer one and will contain everything else-->
           <RelativeLayout> <!-- width: fill, height: wrap, one of these for each row-->
               <ImageView 
                  android:id="@+id/rightArrow"
                  android:layout_alignParentRight="true"/> <!-- This is the arrow that points to the right wrap width and height-->
               <ImageView
                  android:id="@+id/icon"
                  android:layout_alignParentLeft="true"/><!--This is the icon on the left wrap width and height-->
               <TextView
                  android:id="@+id/largeText"
                  android:text="Large Text"
                  android:layout_alignParentBottom="true"
                  android:layout_toLeftOf="@+id/rightArrow"
                  android:layout_toRightOf="@+id/icon"/> <!-- fill width and wrap height-->
               <TextView
                  android:id="@+id/smallText"
                  android:text="Small Text"
                  android:layout_below="@+id/largeText"
                  android:layout_toLeftOf="@+id/rightArrow"
                  android:layout_toRightOf="@+id/icon"/> <!-- fill width and wrap height-->
            </RelativeLayout>
        </LinearLayout>
    

    Or if you prefer (and this is actually probably better), do this:

    <LinearLayout> <!--This is the outer one and will contain everything else-->
       <RelativeLayout> <!-- width: fill, height: wrap, one of these for each row-->
           <ImageView 
              android:id="@+id/rightArrow"
              android:layout_alignParentRight="true"/> <!-- This is the arrow that points to the right wrap width and height-->
         <LinearLayout android android:layout_toLeftOf="@+id/rightArrow"
              ><!--orientation:horizontal, fill width, wrap height-->
           <ImageView
              android:id="@+id/icon"/><!--This is the icon on the left wrap width and height-->
           <TextView
              android:id="@+id/largeText"
              android:text="Large/> <!-- fill width and wrap height-->
           <TextView
              android:id="@+id/smallText"
              android:text="Small Text"/> <!-- fill width and wrap height-->
         </LinearLayout>
        </RelativeLayout>
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
I'm parsing an XML file, the creators of it stuck in a bunch social
I have some data like this: 1 2 3 4 5 9 2 6

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.