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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:59:10+00:00 2026-06-12T07:59:10+00:00

I’m developing an Android 3.0 tablet application. I’m trying to reproduce this Layout: <LinearLayout

  • 0

I’m developing an Android 3.0 tablet application. I’m trying to reproduce this Layout:

    <LinearLayout
        android:weightSum="1"
        android:layout_width="fill_parent"
        android:layout_height="60dip"
        android:orientation="horizontal">


        <TextView
            android:id="@+id/textView1"
            android:layout_weight=".1"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:text="1" />


        <TextView
            android:id="@+id/textView2"
            android:layout_weight=".6"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:text="Defecto 11" />

        <LinearLayout
            android:gravity="center"
            android:layout_weight=".05"
            android:layout_width="0dip"
            android:layout_height="fill_parent" >

        <CheckBox
            android:id="@+id/checkBox1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />
        </LinearLayout>

        <LinearLayout
            android:gravity="center"
            android:layout_weight=".05"
            android:layout_width="0dip"
            android:layout_height="fill_parent" >

        <CheckBox
            android:id="@+id/checkBox2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />
        </LinearLayout>


        <LinearLayout
            android:gravity="center"
            android:layout_weight=".05"
            android:layout_width="0dip"
            android:layout_height="fill_parent" >

        <CheckBox
            android:id="@+id/checkBox3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />
        </LinearLayout>


        <LinearLayout
            android:gravity="center"
            android:layout_weight=".05"
            android:layout_width="0dip"
            android:layout_height="fill_parent" >

        <CheckBox
            android:id="@+id/checkBox4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />

        </LinearLayout>


        <Button
            android:id="@+id/button1"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight=".1"
            android:text="Button" />

    </LinearLayout>

Programmatically:

    LinearLayout layout = new LinearLayout(context);
    LayoutParams parentParams = 
            new LayoutParams(LayoutParams.FILL_PARENT, 60);
    //parentParams.weight = 1;
    layout.setOrientation(LinearLayout.HORIZONTAL);
    layout.setLayoutParams(parentParams);

    // Parámetros para todos los EditText dentro de la tabla.
    LayoutParams params = new LayoutParams(0, LayoutParams.FILL_PARENT);

    // La primera columna es el número del defecto
    TextView textView = new TextView(context);
    params.weight = .1f;
    textView.setLayoutParams(params);
    textView.setGravity(Gravity.CENTER);
    textView.setText(Integer.toString(position));
    layout.addView(textView);

    // La segunda columna es la descripción del defecto.
    params.weight = .6f;
    textView = new TextView(context);
    textView.setLayoutParams(params);
    textView.setGravity(Gravity.CENTER);
    textView.setText(eDefect.getDescription());
    layout.addView(textView);

    LinearLayout chkLayout = new LinearLayout(context);
    LayoutParams chkParams = 
            new LayoutParams(0, LayoutParams.FILL_PARENT);
    chkParams.weight = .05f;
    chkParams.gravity = Gravity.CENTER;
    chkLayout.setLayoutParams(chkParams);

    params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER;
    String eDefectPos = Integer.toString(position);

    // Columna CRS
    String tag = eDefectPos + "_CRS";
    CheckBox chkBox = new CheckBox(context);
    chkBox.setLayoutParams(params);
    chkBox.setTag(tag);
    chkBox.setOnClickListener(checkListener);
    chkLayout.addView(chkBox);
    layout.addView(chkLayout);

    chkLayout = new LinearLayout(context);
    chkLayout.setLayoutParams(chkParams);

    // Columna CRF
    tag = eDefectPos + "_CRF";
    chkBox = new CheckBox(context);
    chkBox.setLayoutParams(params);
    chkBox.setTag(tag);
    chkBox.setOnClickListener(checkListener);
    chkLayout.addView(chkBox);
    layout.addView(chkLayout);

    chkLayout = new LinearLayout(context);
    chkLayout.setLayoutParams(chkParams);

    // Columna MA
    tag = eDefectPos + "_MA";
    chkBox = new CheckBox(context);
    chkBox.setLayoutParams(params);
    chkBox.setTag(tag);
    chkBox.setOnClickListener(checkListener);
    chkLayout.addView(chkBox);
    layout.addView(chkLayout);

    chkLayout = new LinearLayout(context);
    chkLayout.setLayoutParams(chkParams);

    // Columna MI
    tag = eDefectPos + "_MI";
    chkBox = new CheckBox(context);
    chkBox.setLayoutParams(params);
    chkBox.setTag(tag);
    chkBox.setOnClickListener(checkListener);
    chkLayout.addView(chkBox);
    layout.addView(chkLayout);

    // Boton tomar fotos
    params = new LayoutParams(0, LayoutParams.WRAP_CONTENT);
    params.weight = 0.1f;
    tag = eDefectPos;
    Button btnTakePhoto = new Button(mActivity);
    btnTakePhoto.setLayoutParams(params);
    btnTakePhoto.setTag(tag);
    btnTakePhoto.setText(getString(R.string.btn_take_photo));
    btnTakePhoto.setOnClickListener(takePhotoListener);
    layout.addView(btnTakePhoto);

    mLayout.addView(layout, mCurrentDefectTableIndex);

But they don’t like equal.

This with XML:

enter image description here

And this programmatically:

enter image description here

Everything has moved to the right.

Any clue?

  • 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-12T07:59:11+00:00Added an answer on June 12, 2026 at 7:59 am

    You don’t want to re-use a reference to a LayoutParams for different views. If you want to create a “base” params object for re-use, you’ll have to make new references using the LayoutParams constructor that takes a LayoutParams. Like so:

    LayoutParams baseParams = new LayoutParams(0, LayoutParams.FILL_PARENT);
    
    // La primera columna es el número del defecto
    TextView textView = new TextView(context);
    LayoutParams params1 = new LayoutParams(baseParams);
    params1.weight = .1f;
    textView.setLayoutParams(params1);
    textView.setGravity(Gravity.CENTER);
    textView.setText(Integer.toString(position));
    layout.addView(textView);
    
    // La segunda columna es la descripción del defecto.
    LayoutParams params2 = new LayoutParams(baseParams);
    params2.weight = .6f;
    textView = new TextView(context);
    textView.setLayoutParams(params2);
    textView.setGravity(Gravity.CENTER);
    textView.setText(eDefect.getDescription());
    layout.addView(textView);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.