您的位置:首页 > 其它

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

2015-10-22 14:12 375 查看


实现方式:

<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加上方格线,不过如果需求简单,不需要那么麻烦。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  gridview 网格