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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:30:58+00:00 2026-05-29T19:30:58+00:00

I have a GridView that I want to be 4 equally sized TextViews in

  • 0

I have a GridView that I want to be 4 equally sized TextViews in a 2 x 2 GridView. I want the TextViews to be centered within their respective quadrant of the GridView.

My first issue is that nothing is centering. Everything gravitates to the left. My second is that while I can get the column width to size to 50% of the available width, I can’t figure out how to get the row height to adjust to 50% of available height. Weight only seems to work one way.

<GridView  
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/MyGrid"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:padding="5dp"
   android:verticalSpacing="5dp"
   android:horizontalSpacing="10dp"
   android:numColumns="2"
   android:columnWidth="400dp"
   android:stretchMode="columnWidth"
   android:layout_weight=".5"
   android:gravity="center">  
</GridView>

Portrait View
enter image description here

Landscape View
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-29T19:30:59+00:00Added an answer on May 29, 2026 at 7:30 pm

    What you maybe want is to use a TableLayout instead. The GridView is similar to a ListView that has items, but in this case, you want to have only 4 items rather than an indefinite amount.

    GridView

    GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid. The grid items are automatically inserted to the layout using a ListAdapter.

    TableLayout

    TableLayout is a ViewGroup that displays child View elements in rows and columns.

    Here is a snippet of xml that will work:

    <?xml version="1.0" encoding="utf-8"?>
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/MyGrid"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight=".5"
        android:gravity="center"
        android:padding="5dp"
        android:stretchColumns="0,1" >
    
        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1" >
    
            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="Large Text"
                android:textAppearance="?android:attr/textAppearanceLarge" />
    
            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="Large Text"
                android:textAppearance="?android:attr/textAppearanceLarge" />
        </TableRow>
    
        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1" >
    
            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="Large Text"
                android:textAppearance="?android:attr/textAppearanceLarge" />
    
            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="Large Text"
                android:textAppearance="?android:attr/textAppearanceLarge" />
        </TableRow>
    
    </TableLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview that is populated by a dataset and I want to
I have a link in a Gridview that I want opened in Windows Explorer
I have a gridview that takes in values from a sortedlist. I want to
I have a Gridview that I want to filter. My gridview is in an
I have a gridview that I want to read, delete, edit and update, I
I have a gridview that i want to fill with data from my linq
I have a gridview that I want to export to a .csv file. I
In my android app I have a gridview that I want to show images
I have a ListView (GridView) that I want to sort by 2 columns, so
I have a gridview that is databound to a XmlDataSource. I also want to

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.