Android GridView之间的渐变线

Android GridView之间的渐变线,android,gridview,shape,Android,Gridview,Shape,我想在gridview之间画一条如下图所示的线: 下面我已经试过了 GridView XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android

我想在gridview之间画一条如下图所示的线:

下面我已经试过了

GridView XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<GridView
    android:id="@+id/gridhouseindex"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:listSelector="@null"
    android:smoothScrollbar="true"
    android:stretchMode="columnWidth"
    android:numColumns="2"
    android:verticalSpacing="22dp">
</GridView>

适配器XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/imgViewHouseIndex"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal|center"
            android:layout_marginLeft="20dp"
            android:adjustViewBounds="true"
            android:src="@drawable/univer" />

        <TextView
            android:id="@+id/txtViewHouseIndex"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:text="TextView"
            android:textSize="12sp"
            android:textStyle="bold" />
    </LinearLayout>

   <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@drawable/grid_line" />
</LinearLayout>

   <View
        android:layout_width="1dp"
        android:layout_height="match_parent"
        android:background="@drawable/grid_line" />

网格线XML:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

<stroke
    android:width="2dp"
    android:color="#b6a9a9" />

<gradient
    android:angle="90"
    android:endColor="#b6a9a9"
    android:startColor="#FFFFFF" />

<corners
    android:bottomLeftRadius="1dp"
    android:bottomRightRadius="1dp"
    android:topLeftRadius="1dp"
    android:topRightRadius="1dp" />

通过使用上述代码,我得到如下图像:

有人能告诉我,我哪里出错了,或者我必须做什么才能得到准确的输出

更新:


这是我得到的输出。

对于
水平线
行:
gradientbackground.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:dither="true"
    android:shape="rectangle" >
    <gradient
        android:angle="180"
        android:centerColor="#000000"
        android:endColor="#F6F6F6"
        android:startColor="#F6F6F6" />
</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:dither="true"
    android:shape="rectangle" >
    <gradient
        android:angle="270"
        android:centerColor="#000000"
        android:endColor="#F6F6F6"
        android:startColor="#F6F6F6" />
</shape>
对于垂直行:
gradientbackground.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:dither="true"
    android:shape="rectangle" >
    <gradient
        android:angle="180"
        android:centerColor="#000000"
        android:endColor="#F6F6F6"
        android:startColor="#F6F6F6" />
</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:dither="true"
    android:shape="rectangle" >
    <gradient
        android:angle="270"
        android:centerColor="#000000"
        android:endColor="#F6F6F6"
        android:startColor="#F6F6F6" />
</shape>
我希望这能帮到你


谢谢。

谢谢你的回复。我快到目的地了。但我没有得到确切的输出。我将更新问题并添加图像。请参考我的问题。@AbdulRahman您可以从
@RomanGuy的
code:for divider获得参考。感谢您的链接,我将跟进该项目。@Abhan这里的drawble backgrad是什么,我应该在哪里使用这些网格布局view@AbdulRahman你有什么解决办法吗。我也有同样的要求。如果你做完了,请帮助我。