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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:47:15+00:00 2026-06-05T02:47:15+00:00

I wanted to post an image to describe this problem, but apparently I don’t

  • 0

I wanted to post an image to describe this problem, but apparently I don’t have enough of a reputation with stackoverflow yet, so I’m going to try to describe what I am trying to accomplish.

I have a TableLayout with 5 columns. They consist of a company name, a job number, a last name, a graphic vertical divider, and a right arrow button. I would like the divider and right arrow button to be right justified against the right side of the screen. I would like column 2 (the job number) to expand large enough to hold the entire number without wrapping. I would like columns 1 (company name) and 3 (last name) to fill in the rest of the table and use ellipses if they are too big (no text wrapping). My table is built programmatically.

Currently, whenever the company name gets too long, the divider and right arrow get pushed off the right side of the screen.

Here is my layout.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical">
<TextView android:id="@+id/searchResultsFoundTextView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textSize="16dp"
          android:text="@string/searchResultsLabel"/>
<ScrollView android:layout_width="fill_parent"
            android:layout_height="fill_parent">
    <TableLayout android:id="@+id/searchResultsTableLayout"
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 android:layout_marginTop="10dp"
                 android:stretchColumns="1"
                 android:shrinkColumns="0,2" />
</ScrollView>
</LinearLayout>

Here is my code to build the table:

TableLayout table = (TableLayout)findViewById(R.id.searchResultsTableLayout);
for (JobBase job : jobList) {
  TableRow row = new TableRow(this);
  row.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
  row.setPadding(5, 10, 5, 20);
  table.addView(row);

  TextView customerNameTextView = new TextView(this);
  customerNameTextView.setText(job.getCustomerName());
  customerNameTextView.setEllipsize(TextUtils.TruncateAt.END);
  customerNameTextView.setTextSize(FONT_SIZE);
  customerNameTextView.setPadding(10, 5, 10, 0);
  row.addView(customerNameTextView);

  TextView jobNumberTextView = new TextView(this);
  jobNumberTextView.setText(job.getJobNumber());
  jobNumberTextView.setTextSize(FONT_SIZE);
  jobNumberTextView.setPadding(10, 5, 10, 0);
  row.addView(jobNumberTextView);

  TextView crewLeaderTextView = new TextView(this);
  crewLeaderTextView.setText(job.getCrewLeader().getLastName());
  crewLeaderTextView.setEllipsize(TextUtils.TruncateAt.END);
  crewLeaderTextView.setTextSize(FONT_SIZE);
  crewLeaderTextView.setPadding(10, 5, 10, 0);
  row.addView(crewLeaderTextView);

  ImageView dividerImageView = new ImageView(this);
  dividerImageView.setImageDrawable(getResources().getDrawable(R.drawable.btn_med_hl_div_white));
  dividerImageView.setPadding(10, 10, 10, 0);
  row.addView(dividerImageView);

  Button rightArrowButton = new Button(this);
  rightArrowButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.right_arrow_button));
  rightArrowButton.setPadding(10, 0, 10, 0);
  rightArrowButton.setOnClickListener(new RowSelectedAction(row));
  row.addView(rightArrowButton);

  row.setOnClickListener(new RowSelectedAction(row));
}

Any help would be much appreciated.

  • 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-06-05T02:47:16+00:00Added an answer on June 5, 2026 at 2:47 am

    I was able to fix this by adding a weight through LayoutParams to the first column:

    TextView customerNameTextView = new TextView(this);
    customerNameTextView.setText(job.getCustomerName());
    // --- Added this statement
    customerNameTextView.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
    // --- 
    customerNameTextView.setEllipsize(TextUtils.TruncateAt.END);
    customerNameTextView.setTextSize(FONT_SIZE);
    customerNameTextView.setPadding(10, 5, 10, 0);
    row.addView(customerNameTextView);
    

    The first column now expands and contracts and the divider and button are always right justified. Sometimes the customer name is ellipsized and other times the name wraps, but that doesn’t matter to me as long as the column sizes correctly.

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

Sidebar

Related Questions

I'd like to say that I solved the problem but I wanted post this
This wiki post outlines both a problem and a solution. I wanted to post
First I am sorry about the length of this post, but I wanted to
I wanted to make a post request in this website: http://www.prezup.info/index.php?page=films in order to
I wanted to use groovy for a little ftp script and found this post
I have 2 custom post types - offered and wanted. I want these items
I wanted to post this because I was not really sure what issue I
I have this alogirthm problem, in terms of creating mysql tables, let me explain
I know this question might be considered better on Stack UI, but I wanted
I wanted to echo an image every after 3 post via XML here is

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.