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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:20:28+00:00 2026-05-28T20:20:28+00:00

I have a problem with grid view layout on Android. I can’t find solution

  • 0

I have a problem with grid view layout on Android. I can’t find solution to eliminate extra space in grid view. I tried a lot of things (numColumns, columnWidth, stretchMode, gravity) and advices (from StackOverflow), but nothing works correctly. I spent almost 8 hours with this problem. Here is a code of grid view:

<GridView
        android:id="@+id/lookbook_gridview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:listSelector="@null"
        android:padding="0dip"
        android:layout_margin="0dip"
        android:verticalSpacing="0px"
        android:horizontalSpacing="0px"

        android:numColumns="auto_fit"
        android:columnWidth="160px"
        android:stretchMode="columnWidth"
        android:gravity="center" 
        android:layout_gravity="center"

        android:background="#000"
        android:cacheColorHint="#000"
        android:descendantFocusability="afterDescendants"
        android:layout_alignParentTop="true"
        android:layout_above="@id/buttons">
    </GridView> 

I also tried to reduce extra space programically:

private void setGridview()
{  
    GridView gridview = (GridView) findViewById(R.id.lookbook_gridview);
    Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();

    int gridSize = display.getWidth();
    int count = gridSize / 160; // image has 160x160 px
    int colWidth = (gridSize / count) - PADDING;

    gridview.setColumnWidth(colWidth);
    gridview.setNumColumns(count);
}

But it works only on my HTC Desire (right), but on emulator (left) with the same display resolution and the same API version – it is not working.

enter image description here

Does somebody know, how to set images in gridview without any special padding or space to work successfully with all resolutions and devices?

  • 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-28T20:20:28+00:00Added an answer on May 28, 2026 at 8:20 pm

    To solve my problem I used this gridView:

    <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="0dp"
        android:verticalSpacing="2dp" 
        android:horizontalSpacing="2dp"
        android:scrollingCache="true" 
        android:smoothScrollbar="true"
        android:clipChildren="true" 
        android:alwaysDrawnWithCache="true"
        android:numColumns="auto_fit" 
        android:columnWidth="100dp"
        android:stretchMode="columnWidth" 
        android:gravity="center_horizontal"
        android:background="#000000">
    </GridView>
    

    The most important thing is the clipChildren property.

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

Sidebar

Related Questions

I have a rather simple problem with ASP.NET. I have a grid view with
I have problem with DropDownList template in Grid View, after I go in edit
I have a problem. I need to host grid with controls in ScrollViewer to
I'm having a small problem. I have this grid with a column: <data:DataGrid ColumnHeaderStyle={StaticResource
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have a ASP.Net web page with a grid view. I want to filter
I want to have a grid type layout of image views. To begin i
So I have a grid view with checkboxes in it. This is the code
I have a little problem with a Listview. I can load it with listview
I have a grid view populating by users, i want to add to it

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.