GridView加分隔线,最简单的方式实现网格

实现方式:

<GridView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@color/mwhite"
    android:cacheColorHint="@android:color/transparent"
    android:numColumns="3"/>

item.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:background="#CCC2CF"
    android:orientation="vertical"
    android:padding="1px">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@color/mwhite"
        android:padding="@dimen/dp_20">

        <TextView
            android:id="@+id/im_tv_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:drawableTop="@drawable/ic_launcher"
            android:gravity="center" />
    </RelativeLayout>
</LinearLayout>

也可以使用Selector给item加上方格线,不过如果需求简单,不需要那么麻烦。

猜你喜欢

转载自blog.csdn.net/aislli/article/details/49332899