码迷,mamicode.com
首页 > 其他好文 > 详细

GridView网格线都设置

时间:2015-12-12 15:28:42      阅读:273      评论:0      收藏:0      [点我收藏+]

标签:

如今,做网上商店的商品陈列,我想用网络格布局,但总认为空好看。所以我想给它一个净加格线。但是,我遇到了一个问题,网络格布局其实很easy,是集GridView布局和背景颜色adapter布局设置背景颜色参考。

我的设置,如以下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
<GridView
android:id="@+id/gv_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#DCDCDC"
android:horizontalSpacing="1dp"
android:numColumns="2"
android:stretchMode="columnWidth"
android:verticalSpacing="1dp" />

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
<?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="wrap_content"
android:background="@android:color/white"
android:padding="3dp" >
<RelativeLayout
android:id="@+id/rl_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/iv_group_image"
android:layout_width="160dp"
android:layout_height="90dp"
android:layout_centerHorizontal="true"
android:contentDescription="@string/No"
android:scaleType="fitXY" />
<TextView
android:id="@+id/tv_group_desp"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/iv_group_image"
android:layout_below="@id/iv_group_image"
android:layout_marginTop="2dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:lines="2"
android:text="海尔1.5匹无氟冷暖变频挂壁式空调"
android:textSize="14sp" />
<LinearLayout
android:id="@+id/ll_price"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/tv_group_desp"
android:layout_below="@id/tv_group_desp"
android:layout_marginTop="3dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/tv_group_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="¥32"
android:textColor="@color/red"
android:textSize="16sp" />
<TextView
android:id="@+id/tv_group_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="¥21"
android:textColor="@android:color/darker_gray"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/ll_price"
android:layout_below="@id/ll_price"
android:orientation="horizontal" >
<TextView
android:id="@+id/tv_group_discount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:text="2.0折"
android:textColor="#ffff2e2e"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_group_sell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:ellipsize="end"
android:singleLine="true"
android:text="0件已被购买"
android:textColor="@android:color/darker_gray"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>

显示的结果是这种:

技术分享

技术分享

四边被我圈起来了,有木有认为非常难看?反正我是认为难看。这可纠结了,最后最终找到解决的方法了,so easy...就是在GridView布局中加入这样一个属性:

 android:listSelector="@null"

显示效果例如以下:

技术分享

技术分享

怎么样?这不是很值得称道?

GridView网格线都设置

标签:

原文地址:http://www.cnblogs.com/mengfanrong/p/5041177.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!