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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:35:36+00:00 2026-06-01T02:35:36+00:00

I have a layout which I am inflating in order to dynamically add TableRows

  • 0

I have a layout which I am inflating in order to dynamically add TableRows into a TableLayout. I use layout_weight to stretch the columns to the desired width.

The table is put inside a ScrollView so I can scroll between the generated rows. I also have a table header that I put in a LinearLayout on top. I did this because I don’t want to scroll the header. That is also why I don’t use layout_span instead of layout_weight.

The problem is that one of the Views in the TableRow is a CheckBox and I want it centered, but since the layout_width attribute is ‘0’ I can not use layout_gravity="center" to center it.

Here is the xml file:

<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/order_form_line_TableRow"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/order_table_row_product_description_TextView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_weight="0.22"
        android:maxLines="2"
        android:textSize="18sp" />

    <CheckBox
        android:id="@+id/order_table_row_present_CheckBox"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="0.08" />

    <EditText
        android:id="@+id/order_table_row_facings_EditText"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.10"
        android:inputType="number" />

    <EditText
        android:id="@+id/order_table_row_free_cu_given_EditText"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.10"
        android:inputType="number" />

    <EditText
        android:id="@+id/order_table_row_order_quantity_EditText"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.10"
        android:inputType="number" />

    <EditText
        android:id="@+id/order_table_row_free_order_EditText"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.10"
        android:inputType="number" />

    <Spinner
        android:id="@+id/order_table_row_wholesaler_Spinner"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_weight="0.15" />

    <EditText
        android:id="@+id/order_table_row_delivery_date_EditText"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.15"
        android:ellipsize="end"
        android:inputType="date"
        android:singleLine="true" />

</TableRow>

This is how it looks:
CheckBox not centered

This is how I want it to look:
enter image description here

*The colors are for representational purpose only. They can be ignored.

I would very much appreciate it if someone could help. Thank you

  • 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-01T02:35:38+00:00Added an answer on June 1, 2026 at 2:35 am

    try this :

      <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="wrap_content"
            android:gravity="center"
            android:layout_weight="0.08"
            android:layout_height="fill_parent" >
    
        <CheckBox
            android:id="@+id/order_table_row_present_CheckBox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
        </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml layout which I use for each row in my listview:
I have a layout which uses min-width and works great. So I came to
I have a layout in which I am displaying a webview . I want
I have a div in which a page is loaded with the DojoX Layout
I have a layout which contains some views like this: <LinearLayout> <TextView...> <TextView...> <ImageView
I have a layout which specifies sizes of widgets in relative dimension, for example:
I have a layout which has one large EditText view at the top +
I have a panel layout which has some text fields that require validation. What
I have a simple layout which works fine in Chrome, Safari even Opera too
I need a method of inserting javascript which is controller/action specific into a layout.

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.