簡體   English   中英

使StickyGridHeadersGridView布局中心對齊?

[英]Make StickyGridHeadersGridView layout center aligned?

我正在使用StickyGridHeadersGridView在應用程序中顯示預訂位。 事情一切正常,但是插槽的位置就像它們在匹配父級中一樣。 一次將顯示3個或4個插槽。 因此,如果將其居中對齊,則觀看起來會更加令人愉悅。 試圖在沒有幫助的情況下進行許多調整。 在下面發布xml代碼。

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>

需要使其居中對齊。

請嘗試這個。 我更改了它的某些屬性。 所以請檢查這是您想要的嗎?

<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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM