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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:13:45+00:00 2026-06-10T19:13:45+00:00

I have GridView: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent android:layout_height=match_parent android:id=@+id/frag_books_grid_view_layout android:orientation=vertical> <GridView android:cacheColorHint=@color/bg_default

  • 0

I have GridView:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:id="@+id/frag_books_grid_view_layout"
     android:orientation="vertical">
        <GridView
            android:cacheColorHint="@color/bg_default"
            android:listSelector="@drawable/list_selector_background"
            android:id="@+id/frag_books_grid_view"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:columnWidth="120px"
            android:gravity="center"
            android:horizontalSpacing="15dp"
            android:scrollbars="none"
            android:stretchMode="columnWidth"
            />
</LinearLayout>

And single item (placed in cell of this grid):

<ListView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:cacheColorHint="@color/bg_default"
    android:scrollbars="none"
    android:listSelector="@drawable/list_selector_background"
    android:layout_gravity="center_vertical|left"
    android:gravity="center_vertical|left"
    android:padding="15dp"
    android:id="@+id/frag_book_list_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:verticalSpacing="5dp"/>

How it looks: https://i.stack.imgur.com/2q51E.png
Everything is fine with blue selection, but the contents of the cell is not centered inside of it.
This picture explains what I want: https://i.stack.imgur.com/6o8zh.png

  • 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-10T19:13:47+00:00Added an answer on June 10, 2026 at 7:13 pm

    Besides it’s not recommended to have nested scrollable components, you have the dimensions of list view set to match_parent. So it’s not possible to center, since it’s already occupying all available space.

    If you want to center, you first have make the listView smaller (setting fixed size). And then use gravity=”center” on the container. You also can apply a uniform padding to the container, this will also make the listView look centered.

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

Sidebar

Related Questions

I have a grid_test.xml <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/linearLayoutGrid android:layout_width=fill_parent android:layout_height=fill_parent > <GridView
I have a GridView like this( main.xml ): <?xml version=1.0 encoding=utf-8?> <GridView xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/gridView1
I have the following code in resultlookup.xml <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:id=@+id/layoutResultOuter
I have the following layout: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent> <GridView android:id=@+id/grid
I have Data.xml: <?xml version=1.0 encoding=utf-8 ?> <data> <album> <slide title=Autum Leaves description=Leaves from
I have created bg3.9.png image following this tutorial http://developer.android.com/guide/developing/tools/draw9patch.html but when i put it
How can I create xml file with this format using c#? <?xml version=1.0 encoding=utf-8
I have a GridView which is databound to an XML Datasource. For one of
I have a GridView in android which I fill it with data retrieved from
I have a LinearLayout in my android application. Worked well with just the two

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.