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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:46:05+00:00 2026-06-09T15:46:05+00:00

I have a gridview, with a set number of columns (let’s say, 5). However,

  • 0

I have a gridview, with a set number of columns (let’s say, 5). However, if I have 6 images set in my image adapter, the 6th one automatically goes to a new row, and is assigned the first column. The behavior I am looking for would be to automatically (or programmatically, somehow) center that extra child element in the new row… like this for example:

A B C D E
    F

Here is the XML that I have for the gridview:

<GridView android:id="@+id/gridview" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:columnWidth="10dip"
android:numColumns="10" android:horizontalSpacing="10dip"
android:stretchMode="columnWidth"
xmlns:android="http://schemas.android.com/apk/res/android"
android:verticalSpacing="3dp"
android:layout_below="@+id/TopLayout"
android:layout_gravity="center"></GridView>
  • 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-09T15:46:07+00:00Added an answer on June 9, 2026 at 3:46 pm

    You can’t change the number of cols for a given row. The only trick I can think of is to use an odd number of columns and insert void entries in the list your adapter is based on. E.g. if you have 5 cols and 6 images, insert 2 void entries at positions 5 and 6 so your last image will be centered.

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

Sidebar

Related Questions

i need to set image as background in android gridview. I have code which
I have a set of 12 images to show in a layout. The number
I have to set GridView.DataKeyNames (This is really a question about the syntax for
So, I have a GridView with an ObjectDataSource, and I want to programmatically set
I have a asp:GridView with a HyperLinkField . It's DataNavigateUrlFormatString property is set to
I have a gridview that is set to a sql datasource, it is generating
I have a XtraGrid with one GridView, with a column with checkbox repository item.
I have a GridView control on my ASP.NET page that binds to result set
Simply, if I have a GridView with a SqlDataSource control declarative set as its
In my android app I have a gridview that I want to show images

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.