Re: [android-developers] Why doesn't layout_alignCenterInParent work?
I would assume that GridView does not support wrap_content for
android:layout_height, no different that ListView. I'm not sure it
supports wrap_content for android:layout_width, either. And, of
course, your RelativeLayout doesn't have the attribute in your post
title, though I assume that's a copy/paste issue. :-)
Try it with a GridView with fixed dimensions and see what happens.
On Sun, Dec 4, 2011 at 5:41 PM, Christopher Van Kirk
<christopher.vankirk@gmail.com> wrote:
> I've tried several times now to use android:layout_alignCenterInParent to
> center a child in its parent RelativeLayout view, but it never seems to
> work.
>
> What's wrong with this code, and why doesn't it center the GridView in the
> outer RelativeView?
>
> <?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/select_grid"
> android:layout_width="wrap_content"
> android:layout_height="wrap_content"
> android:layout_centerInParent="true"
> android:numColumns="3"
> android:columnWidth="90dp"
> android:stretchMode="none"
> android:gravity="center"
> android:verticalSpacing="10dp"
> android:horizontalSpacing="10dp"
> android:layout_marginLeft="20dp"
> android:layout_marginRight="20dp" >
> </GridView>
> </RelativeLayout>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy
Android Training...At Your Office: http://commonsware.com/training
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home