• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Centralize a GridLayout

lPing7

Lurker
I have a GridLayout sitting inside a RelativeLayout.

HTML:
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <GridLayout

        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:rowCount="5"
[INDENT]android:layout_marginTop="24dp"[/INDENT]
        android:layout_centerHorizontal="true"
        android:columnCount="7">
I have a bunch of buttons within this GridLayout. (I just used html to add this code here. It as an xml file though)

This is the output currently:
2wddhl2.jpg


I want the GirdLayout to be centralised, with a margin of 24dp on top. I'm able to get the top margin, but not able to center the Grid. Any help is appreciated.

Thanks
Pings
 
Last edited:
Back
Top Bottom