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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:41:27+00:00 2026-05-23T10:41:27+00:00

Trying to make toolbar with two buttons on both sides and header between. Header

  • 0

Trying to make toolbar with two buttons on both sides and header between. Header should be ellisized when text is too long, like this:

[Button] Some quite long header te... [Button]

I’ve tried several solutions, but none help. My last try was something like this:

<TableLayout android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:background="#444"
             android:stretchColumns="1">
    <TableRow android:background="#777" android:minHeight="60dp">
        <Button android:text="Left"/>
        <TextView android:text="Center this very long text and ellisize"
                  android:background="#f00"
                  android:lines="1"
                  android:ellipsize="end"
                  android:scrollHorizontally="true"
                  android:gravity="center"
                />
        <Button android:text="Right"/>
    </TableRow>
</TableLayout>

But right button still goes away from screen…

UPDATE:
The solution is:

<RelativeLayout android:layout_width="fill_parent" android:layout_height="64dip">
    <Button android:id="@+id/btnLeft"
            android:text="Left"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    <Button android:id="@+id/btnRight"
            android:text="Right"
            android:layout_alignParentRight="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    <TextView android:text="Center this very long text and ellisize"
              android:layout_width="fill_parent" android:layout_height="fill_parent"
              android:background="#f00"
              android:lines="1"
              android:ellipsize="end"
              android:gravity="center"
              android:scrollHorizontally="true"
              android:layout_toLeftOf="@id/btnRight"
              android:layout_toRightOf="@id/btnLeft"
            />
</RelativeLayout>

UPDATE 2: And the second solution using TableLayout:

<TableLayout android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:background="#444"
             android:stretchColumns="1"
             android:shrinkColumns="1">
    <TableRow android:background="#777" android:minHeight="60dp">
        <Button android:text="Left"/>
        <TextView android:text="Center this very long text and ellisize"
                  android:background="#f00"
                  android:lines="1"
                  android:ellipsize="end"
                  android:scrollHorizontally="true"
                  android:gravity="center"
                />
        <Button android:text="Right"/>
    </TableRow>
</TableLayout>
  • 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-23T10:41:28+00:00Added an answer on May 23, 2026 at 10:41 am

    Try using a relative layout instead of a table layout. If you set up the two buttons to be aligned left and right respectively, you can set the text field to span between the two buttons with the layout_alignRight and layout_alignLeft properties. You can look at the example code for the RelativeLayout given on the android development website.

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

Sidebar

Related Questions

I am trying make long screen to vertical direction. So, I need a screen
I'm trying to make a thumbnail toolbar button (TTB from now on)visible when the
Im trying to make a recreation of MSWord using WPF RichTextBox and Toolbar, so
I'm trying to make a text editor with a JTextPane, but i'm having trouble
I'm trying to make a iPad like toobar at the bottom of my webpage,
I am making a homemade text editor and in it trying to make a
I'm trying to make a back button in a toolbar in jquery mobile for
I am trying to make a thumbnail toolbar for which I need an icon.
I am trying to recreate the nice textured buttons like Finder, Safari and Transmission
Trying to make a make generic select control that I can dynamically add elements

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.