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

  • Home
  • SEARCH
  • 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 955163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:20:12+00:00 2026-05-16T00:20:12+00:00

Ok, my problem is, I have got n-TextViews and they will be added programmatically

  • 0

Ok, my problem is, I have got n-TextViews and they will be added programmatically into a TableLayout. It totally doesnt matter, how I style these TextViews or the TableLayout, everytime I add something, it adds the TextView on the bottom after the other TextViews.
These Views have got a variable width, which is calculated out of their textlength and some pixels (WRAP_CONTENT just made 100% width…).

It is like this right now:
------------------------------------------
[TextView 1]
[TextView 2]
[TextView 3]
[TextView 4]
------------------------------------------

And it should be like:
------------------------------------------
[TextView 1] [TextView 2] [TextView 3]
[TextView 4]
------------------------------------------

Actually I dont need a TableLayout. I still can change it in whatever you want. Of course it would be even better if those TextViews can get WRAP_CONTENT as width.

EDIT:
Btw. a LinearLayout with orientation=”horizontal” adds the TextViews at first corret, but on the end it doesn’t wrap to the next line, it just adds them to the right side and it will be splitted, like:

------------------------------------------
[TextView 1] [TextView 2] [TextView 3] [Te
                                       [xt
                                       Vie
                                       w 4
                                       ]
------------------------------------------
  • 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-16T00:20:13+00:00Added an answer on May 16, 2026 at 12:20 am

    I think you could try something like that :
    – Put a TableLayout as root of your Activity, with FILL_PARENT as width and height.
    – Then get its width and store it in a variable (mWidth).
    – you create a TableRow, add a first TextView and store its width in a variable (mTotalWidth), and you put the TextView in the row.
    – When you want to add a new Textview, you create it, get its width and calculate the sum when you add it to mTotalWidth.
    Now
    if mTotalWidth < mWidth , you add your TextView into the current row and increment mTotalWidth
    else you create a new TableRow, put your Textview in it, and change the value of mTotalWidth to the width of this TextView.
    Then you can repeat this for all your views. This can appear a bit messy but I think it could work.

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

Sidebar

Ask A Question

Stats

  • Questions 485k
  • Answers 485k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If I'm correct those paths are set in the share/autoconf/autoconf/general.m4… May 16, 2026 at 7:43 am
  • Editorial Team
    Editorial Team added an answer As mentioned by many people here, this is a standard,… May 16, 2026 at 7:43 am
  • Editorial Team
    Editorial Team added an answer After onCreate() is invoked, will the ContentProvider persist unconditionally for… May 16, 2026 at 7:43 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.