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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:12:15+00:00 2026-05-22T23:12:15+00:00

I have one little problem…Here is my code..Is there a way to distribute weights

  • 0

I have one little problem…Here is my code..Is there a way to “distribute weights evenly” for those buttons what I made.. I tried to button[i].setWidth().. but when I turn around my phone it looks ugly.. so Is there away to distribute buttons width auto?

    ViewGroup row1 = (ViewGroup)findViewById(R.id.TableRow02);
    ViewGroup row2 = (ViewGroup)findViewById(R.id.TableRow04);
    ViewGroup row3 = (ViewGroup)findViewById(R.id.TableRow06);
    ViewGroup row4 = (ViewGroup)findViewById(R.id.TableRow08);
    ViewGroup row5 = (ViewGroup)findViewById(R.id.TableRow10);

    Button button[] = new Button[36];
    for(int i=1;i<36;i++)
    {
        button[i] = new Button(this);

        if(i==32||i==33||i==34||i==35){button[i].setVisibility(-1);}

        button[i].setText("700€");
        button[i].setTextSize(10);
        button[i].setWidth(20);

     // Insert buttons in rows
        if(i<8){row1.addView(button[i]);}
        else if(i<15){row2.addView(button[i]);}
        else if(i<22){row3.addView(button[i]);}
        else if(i<29){row4.addView(button[i]);}
        else if(i<36){row5.addView(button[i]);}
    }
  • 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-22T23:12:16+00:00Added an answer on May 22, 2026 at 11:12 pm

    Tactically, put the buttons in a LinearLayout and set android:layout_weight="1" for each of them.

    Strategically, design a decent UI, one that does not involve a row of 36 buttons.

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

Sidebar

Related Questions

Please excuse (or improve the title) but I have a silly little problem that's
I have made a little gallery ( http://www.kongeboa.dk/billeder/3/Coco/ ) If you refresh, and choose
I have a question regarding some JavaScript, there is a big picture and the
I just ran across a problem that took a little while to figure out
[Apologies if my question title does not accurately describe my problem- if you can
On my page I have a lot of various elements which respond to click
At the moment I'm working on a system that caches dynamically created files, nothing
I am writing a Tetris-based game, and I am using a GridLayout to display
First I'm going to explain what I'm trying to do and then explain my

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.