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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:02:40+00:00 2026-05-25T21:02:40+00:00

I am having issues in TableLayout, width issues. I tried searching a lot, but

  • 0

I am having issues in TableLayout, width issues. I tried searching a lot, but all I get is solution using xml. I am doing it programmatically. Here is what I am doing

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    TableLayout table = new TableLayout(this);
    table.setStretchAllColumns(true);
    table.setShrinkAllColumns(true);


    TableRow tableTitle = new TableRow(this);
    tableTitle.setGravity(Gravity.CENTER_HORIZONTAL);

    TableRow name = new TableRow(this);
    TableRow password = new TableRow(this);
    TableRow button = new TableRow(this);

    TextView empty = new TextView(this);

    TextView title = new TextView(this);
    title.setText("Hello table layout");
    title.setGravity(Gravity.CENTER_HORIZONTAL);

    TextView txtUname = new TextView(this);
    txtUname.setText("Username");

    TextView txtPass = new TextView(this);
    txtPass.setText("Password");


    EditText uname = new EditText(this);
    EditText pass  = new EditText(this);

    Button login = new Button(this);
    login.setText("Login");

    name.addView(txtUname);
    name.addView(uname);

    password.addView(txtPass);
    password.addView(pass);

    button.addView(empty);
    button.addView(login);

    table.addView(name);
    table.addView(password);
    table.addView(button);

    table.setColumnShrinkable(0, true); 

    setContentView(table);
}

I want to shrink first column. What should I add in this code?

Anyone help!

  • 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-25T21:02:41+00:00Added an answer on May 25, 2026 at 9:02 pm

    You should consider moving your to layout xml file. This would make your life way easier.

    To make only first column shrinkable replace setShrinkAllColumns(true)
    with setColumnShrinkable(0, true).

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

Sidebar

Related Questions

I'm having issues creating an ActionLink using Preview 5. All the docs I can
I'm having issues parsing some XML using DefaultHandler2. My XML takes the following form:
I'm having issues with my SQL Reporting Services reports. I'm using a custom font
I am having issues converting a png to tiff. The conversion goes fine, but
I am having issues with some xml parsing. I want the data to be
Im having issues trying to get a custom snapin to display in the Add/Remove
I'm having issues with my webserver and iPhone app, considering the timezone. It's all
I am having issues testing which icon my notifyIcon is using. I have a
Having issues getting links that match a given word to display using Xpath and
Having issues using cURL on windows vista. The library is there and showing with

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.