简体   繁体   中英

Make StickyGridHeadersGridView layout center aligned?

I'm using StickyGridHeadersGridView for showing booking slots in an application. Thing is it is working fine and all, but the slots are placed like they are in match parent. At a time mostly 3 or 4 slots will be shown. So, if it's centrally aligned it will look more pleasing to watch. Tried doing many tweaks with no help. Posting the xml code below.

main.xml

<RelativeLayout
        android:id="@+id/lin_slots_layout"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_marginTop="10dp"
        android:gravity="center"
        android:orientation="horizontal">


        <include
            android:id="@+id/layoutGrid"
            layout="@layout/slot_grid_slide"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_centerInParent="true"
            android:layout_gravity="center"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:padding="10dp"
            android:visibility="visible" />

    </RelativeLayout>

layoutGrid

<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
    android:id="@+id/gridLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:background="@color/lightgrey"
    android:gravity="center"
    android:orientation="vertical"
    >
    <com.bestdocapp.kiosk_opd.utils.stickygridheaders.StickyGridHeadersGridView
        android:id="@+id/session"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_centerInParent="true"
        android:background="@color/bmh_home_background_color"
        android:clipToPadding="false"
        android:columnWidth="0dp"
        android:gravity="center"
        android:horizontalSpacing="0dp"
        android:numColumns="5"
        android:textAlignment="center"
        android:verticalSpacing="2dp"
        />
</RelativeLayout>

Need to make it centrally aligned.

Please try this. I've changed some of its properties . so please check this is what you want ?

<RelativeLayout
    android:id="@+id/gridLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:background="@color/lightgrey"
    android:gravity="center"
    android:orientation="vertical"
    >
    <com.bestdocapp.kiosk_opd.utils.stickygridheaders.StickyGridHeadersGridView
        android:id="@+id/session"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="@color/bmh_home_background_color"
        android:clipToPadding="false"
        android:columnWidth="100dp"
        android:gravity="center"
        android:horizontalSpacing="5dp"
        android:numColumns="5"
        android:textAlignment="center"
        android:verticalSpacing="2dp"
        />
</RelativeLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM