android - Add space to top and bottom of GridView -
i add space top , bottom of gridview, similar header/footer wanted support spaces , nothing else.
currently using top/bottom padding, when scrolled content cropped in padding part.
what's simplest solution this? thanks!
instead of using paddings (which add space inside view), use margins (which add space ouside view):
add
android:layout_margintop="40dp" android:layout_marginbottom="40dp"
to gridview (or different value)
[edit]
as per op's clarification: "spaces" must fixed , gridview scrollable.
therefore i'm designing (by setting pair of anchored textviews act fixed header , footer):
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" android:padding="8dp" > <!-- header --> <textview android:id="@+id/txtheader" android:layout_width="match_parent" android:layout_height="48dp" android:layout_alignparenttop="true" android:background="#ff00" android:gravity="center" android:text="header" android:textcolor="@android:color/white" android:textsize="24sp" android:textstyle="bold" /> <!-- footer --> <textview android:id="@+id/txtfooter" android:layout_width="match_parent" android:layout_height="48dp" android:layout_alignparentbottom="true" android:background="#ff00" android:gravity="center" android:text="footer" android:textcolor="@android:color/white" android:textsize="24sp" android:textstyle="bold" /> <!-- grid --> <!-- <gridview --> <!-- android:id="@+id/grdicons" --> <!-- android:layout_width="match_parent" --> <!-- android:layout_height="match_parent" --> <!-- android:layout_above="@id/txtfooter" --> <!-- android:layout_below="@id/txtheader" --> <!-- android:background="#f0f0" --> <!-- android:textcolor="@android:color/white" --> <!-- android:textsize="24sp" --> <!-- android:textstyle="bold" --> <!-- /> --> <gridview android:id="@+id/grdicons" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@id/txtfooter" android:layout_below="@id/txtheader" android:background="#f00f" android:textcolor="@android:color/white" android:textsize="24sp" android:textstyle="bold" android:columnwidth="64dp" android:numcolumns="auto_fit" android:verticalspacing="8dp" android:horizontalspacing="8dp" android:stretchmode="none" android:gravity="center" /> </relativelayout>
in example, headers visible (red , text), can cut off part relative text attributes , set color #0000 (transparent)
here's result:
Comments
Post a Comment