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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:22:07+00:00 2026-05-23T17:22:07+00:00

My Android app has a table with seven columns. I’d like to change the

  • 0

My Android app has a table with seven columns. I’d like to change the background color of these columns when the content in the table is updated. How do I specify columns in the main.xml and how do I change their background color? Thanks.

Edit main.xml posted…

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:background="#CDCDCD" android:orientation="vertical">
    <TableLayout android:id="@+id/tableLayout1" android:layout_width="match_parent" android:layout_height="wrap_content">
        <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">
            <TextView android:text="100" android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="1"></TextView>
            <TextView android:text="100" android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="2"></TextView>
            <TextView android:text="100" android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="3"></TextView>
            <TextView android:text="100" android:id="@+id/textView5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="4"></TextView>
            <TextView android:text="100" android:id="@+id/textView6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="5"></TextView>
            <TextView android:text="100" android:id="@+id/textView7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="6"></TextView>
            <TextView android:text="100" android:id="@+id/textView8" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="7"></TextView>
        </TableRow>
        <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content">
            <TextView android:text="100" android:id="@+id/textView11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="1"></TextView>
            <TextView android:text="100" android:id="@+id/textView12" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="2"></TextView>
            <TextView android:text="100" android:id="@+id/textView13" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="3"></TextView>
            <TextView android:text="100" android:id="@+id/textView14" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="4"></TextView>
            <TextView android:text="100" android:id="@+id/textView15" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="5"></TextView>
            <TextView android:text="100" android:id="@+id/textView16" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="6"></TextView>
            <TextView android:text="100" android:id="@+id/textView17" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="7"></TextView>
        </TableRow>
    </TableLayout>
</LinearLayout>

EDIT:

This is an example of why I want to highlight the entire column instead of the individual textviews. When I highlight the individual textviews they are different sizes so they do not expand to the width of the widest textview in that column. Unless anyone knows how to change the size of my text views to fit the size of the widest textview in each column. If anyone does know this, please post.

uneven highlighting

EDIT:
Results of adding layout_weight properties to the TableRow tag…

enter image description here

I also tried the same thing but added the layout_weight property to the TextView tag instead. Here is the result…

enter image description here

  • 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-23T17:22:08+00:00Added an answer on May 23, 2026 at 5:22 pm

    To give your textviews equal width and therefore fix your higlighting issue you should look at the layout_weight property

     <?xml version="1.0" encoding="utf-8"?>
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent"
         android:background="#CDCDCD" 
         android:orientation="vertical">
      <TableLayout android:id="@+id/tableLayout1" android:layout_width="match_parent"              android:layout_height="wrap_content">
         <TableRow 
            android:id="@+id/tableRow1"
            android:layout_width="0dip" 
            android:layout_height="wrap_content" 
            android:layout_weight="0.5">
            <TextView android:text="100" android:id="@+id/textView2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_column="1"></TextView>
        </TableRow>
        <TableRow   
           android:id="@+id/tableRow2" 
           android:layout_width="0dip" 
           android:layout_height="wrap_content" 
           android:layout_weight="0.5">
            <TextView android:text="100" android:id="@+id/textView11" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_column="1"></TextView>            
        </TableRow>
      </TableLayout>
    </LinearLayout>
    

    Now I’m not at my development PC so can’t verify this (and fix my formatting), but it should work I’ll check it later.

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

Sidebar

Related Questions

I've got an Android app which has a periodic background Service. I want this
I'm creating android app that has table layout for the main activity, and that
I have an Android app that has a Content Provider with an SQLiteDatabase implementation.
My android app has a two word app name, and the 2nd word doesn't
I've got some XML resources in my Android app. Each one has a different
I'm writing an Android app where users can upload video to Youtube. I'd like
I am mking an android app in which i am making dynamically table rows
My Android app has a WebView that requires the Flash plugin. The webview will
I'm looking for a way to detect that my android app has been backgrounded,
Working on an Android app where I would like to display the number of

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.