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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:11:56+00:00 2026-06-10T22:11:56+00:00

I have a Layout to which i dynamically add rows to. Each row consists

  • 0

I have a Layout to which i dynamically add rows to. Each row consists of a TextView and an EditText. Now the texts for the EditText are set at runtime, so i want them all to be neatly alligned like a inout form where a textfield is at the left and an edittext on the right.

This my code

for (int i = 0; i < itemsContainer.getChildCount(); i++) 
    {
        View v=itemsContainer.getChildAt(i);
        if(v instanceof ClickableButtonView)
        {
            TextView textView=((ClickableButtonView)v).getItem();
            if(textView.getWidth() > width)
            {
                width=textView.getWidth();
            }
        }

    }

    for (int i = 0; i < itemsContainer.getChildCount(); i++) 
    {
        View v=itemsContainer.getChildAt(i);
        if(v instanceof ClickableButtonView)
        {
            TextView textView=((ClickableButtonView)v).getItem();
            textView.setLayoutParams(new LayoutParams(width, LayoutParams.WRAP_CONTENT));
        }

    }

Now what happens is that my layout, with the textview collapses, and only the element on the right side takes up the complete space. I want to iterate over the LineraLyout, find the edittext that is taking the most room and set the all the edittext to take up the exact same room. Can this be done ?

  • 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-10T22:11:58+00:00Added an answer on June 10, 2026 at 10:11 pm

    Call this method in a loop to set the style for your textviews with any weights required. Giving weight 1 to all will make it equal.

    private void setStyle(TextView textView, float weight) {
        textView.setSingleLine(false);
        textView.setWidth(0);
        textView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT, weight));
        textView.setPadding(8, 0, 8, 0);
        textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a layout which I am inflating in order to dynamically add TableRows
I have an xml layout which I use for each row in my listview:
I have created a table layout in which my table row height is too
I have a linear layout (horizontal) inside which there is 3 linear layouts, each
I have a problem with a TableRow, which I add dynamically. private void addRow(String
I have a grid which is dynamically added to the Layout-root which could have
I have a layout which looks like this: <LinearLayout> <ImageView> android:width=wrap_content android:height:wrap_content ... </ImageView>
I have a layout setup which can be view here: http://jsfiddle.net/Pn3ts/ It all works
Help needed.. I have a organization layout which have rectangular shapes not in an
I have a quite complicated HTML/CSS layout which I would like to convert to

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.