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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:27:35+00:00 2026-05-28T07:27:35+00:00

I am trying to display a GridView in a Dialog. Despite all my efforts,

  • 0

I am trying to display a GridView in a Dialog. Despite all my efforts, the GridView width grows to the entire screen, instead of wrapping to the columns. The layout and an image depicting the issue are below (I set a background color for the GridView to illustrate the issue).

<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/colorgridview"
    android:background="#FF00CCBB"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:numColumns="4"
    android:verticalSpacing="5dp"
    android:horizontalSpacing="5dp"
    android:columnWidth="70dp"
    android:stretchMode="none"
/>

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-28T07:27:36+00:00Added an answer on May 28, 2026 at 7:27 am

    I know that this post is a bit outdated. But if someone needs a solution to this, this answer may come in handy.

    It is possible to set the view’s width after screen measurement.

    To do this:

    Let your class implement the OnGlobalLayoutListener.
    The screen is measured when the onGlobalLayout method is called. We can do our magic here.
    GridView.getLayoutParams().width = ….

    edit:
    I wasn’t very clear on how to add the onGlobalLayoutListener. See plugmind’s post, he shows how to add it.
    Can't figure out how to get view/layout width/height

    Kind regards,
    Bram

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

Sidebar

Related Questions

I am trying to display an image in a gridview, however, the columns that
I have an ASP Datalist with a nested GridView. I am trying to display
I'm trying to display all the 'legs' for each of my 'trips' in my
I am trying to display all possible values for a sub-property. Below I am
I'm trying to display records within my GridView and a few of the cells
Sorry for troubling. Im trying to display the selected fields in a asp.net gridview.
Hi everyone I'm trying to display some images using a GridView. However I'm getting
I am trying to use the wildcard query to display rows in a gridview
I'm working on my first Windows 8 app. I'm trying to display a GridView
I'm trying to display some data from a Stored Procedure into my GridView .

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.