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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:49:11+00:00 2026-05-20T11:49:11+00:00

I’m trying to get a row of text which will be something like foofoofoo

  • 0

I’m trying to get a row of text which will be something like

foofoofoo – barbarbar

but I want it to ellipse foo and bar if it won’t fit on one line.
i.e. I’m trying to shorten them down.

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView android:id="@+id/text_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:maxWidth="0dip"
        android:layout_weight="1"
        android:textColor="#ffffff"
        android:singleLine="true"
        android:ellipsize="true"
        android:text="foofoofoofoo" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#ffffff"
        android:text=" - " />
    <TextView
        android:id="@+id/text_2"
        android:layout_width="wrap_content"                         
        android:layout_height="wrap_content"
        android:maxWidth="0dip"
        android:layout_weight="1"
        android:textColor="#ffffff"
        android:singleLine="true"
        android:ellipsize="true"
        android:text="barbarbarbar" />
</LinearLayout>

Bear with me this works partially.

Setting the TextView‘s layout_width to be 0dip and layout_weight to be 1 means they will take up 50% of the available space each.

Setting the singleLine to true and ellipsize to true means they will look like foofoo… if the text is larger than the container.

Therefore my outcome (if the text is longer) should be

foofoo.. – barbar..

Which it is! So this works.

Now the case I’m trying to fix is, if the first TextView (id:text_1) has text that is less than the 50% given by layout_width="0dip" and layout_weight="1" I want it to wrap_content. Otherwise it looks like:

foo blank space – barbar..

and I want

foo – barbarbar

This is why I have changed layout_width="wrap_content" and added android:maxWidth="0dip" but this doesn’t work! It seems to be ignoring me saying wrap_content and still giving this view 50%!

I read that you need to add android:adjustViewBounds="true" for maxWidth to work but this had no affect.

  • 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-20T11:49:11+00:00Added an answer on May 20, 2026 at 11:49 am

    This is the best I could do, try changing the strings to see if it works as intended.

    <?xml version="1.0" encoding="utf-8"?>
    <TableLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:shrinkColumns="0,2"
        android:stretchColumns="0,2">
        <TableRow>
            <TextView android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:ellipsize="end"
                android:text="foofoofoo"/>
            <TextView android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="-"
                android:gravity="center_horizontal"/>
            <TextView android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:ellipsize="end"
                android:text="barbarbarbarbarbarbarbarbarbarbarbar"/>
        </TableRow>
    </TableLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I have a text area in my form which accepts all possible characters from
I want to construct a data frame in an Rcpp function, but when I
Basically, what I'm trying to create is a page of div tags, each has

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.