2014-02-05 43 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并提供所需的保证金。对于具有在右侧和在底部的黑线网格视图项