2014-02-05 45 views
0

我是新來的GridView佈局GridView控件。你能幫我解決我們如何添加分隔符/分隔符到網格視圖,如我們對錶 請找到下面的圖像enter image description here添加列邊框在android系統

+0

使用9-補丁圖像,還可以使用另一個9膜片用於具有在頂部和左側黑色linrs網格視圖本身 – pskink

回答

0

可悲的是沒有自動的方式來做到這一點。你可以試試這個。在表格中的每個視圖周圍設置1或2像素填充,並且您應該有一個邊框。

來源:Android GridView with Separator

0

要創建這種類型的佈局,你必須一幀分配給你的GridView項目。讓我們考慮這是你的項目的佈局: -

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

在上面的佈局您可以將幀分配給GridViewItem並提供所需的保證金。對於具有在右側和在底部的黑線網格視圖項