0

I am new to gridview layout. could you please help me out how can we add divider/separator to grid view, as we have for tables Please find the below imageenter image description here

Amit Chauhan
  • 6,151
  • 2
  • 24
  • 37
  • use 9-patch images for grid view items that have black lines on the right and on the bottom, also use another 9 patch for the grid view itself that has black linrs on the top and on the left – pskink Feb 05 '14 at 13:42

2 Answers2

0

Sadly there is no automatic way to do this. You could try this. Set a 1 or 2 pixel padding around each View in the table, and you should have a border between.

Source : Android GridView with Separator

Community
  • 1
  • 1
Hbibna
  • 568
  • 7
  • 11
0

To create such type of layout you have to assign a Frame to your GridView Item. Lets consider this is your Item's layout :-

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000" >

<ImageView
    android:id="@+id/image_view_product_cell_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:contentDescription="@string/image_content_description" />

<RelativeLayout
    android:id="@+id/rel_lay_product_image_frame_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/image_view_product_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/image_content_description" />

    <ImageView
        android:id="@+id/image_view_product"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/image_content_description" />

    <ProgressBar
        android:id="@+id/progress_bar_product"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:indeterminateDrawable="@drawable/custom_progress_bar"
        android:indeterminateDuration="800" />
</RelativeLayout>

<TextView
    android:id="@+id/text_view_product_title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ellipsize="end"
    android:gravity="center"
    android:singleLine="true"
    android:textIsSelectable="true" />

<TextView
    android:id="@+id/text_view_product_brand"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/text_view_product_title"
    android:gravity="center"
    android:singleLine="true"
    android:textIsSelectable="true" />

in the above layout you can assign your frame to the GridViewItem and provide required margin.

Amrut
  • 2,655
  • 3
  • 24
  • 44