GridView网格线设置

今天在做网上商城的商品显示,想用网格布局,可是总觉得空空的不好看,所以就想着给它加个网格线,可是遇到问题了,网格布局其实很简单,就是设置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网格线设置,布布扣,bubuko.com

时间: 2024-08-10 13:40:03

GridView网格线设置的相关文章

DevExpress TreeList GridView 样式设置

1.GridView 样式设置 this.gridViewUser.PaintStyleName = "Flat"; 2.TreeList 样式设置 this.treeListDep.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat; this.treeListDep.LookAndFeel.UseDefaultLookAndFeel = false;

GridView网格线都设置

如今,做网上商店的商品陈列,我想用网络格布局,但总认为空好看.所以我想给它一个净加格线.但是,我遇到了一个问题,网络格布局其实很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=&quo

解决GridView动态设置宽高导致第一个item点击不响应或显示不正常问题

最近做项目的时候遇到了2次这个问题,现在分享一下经验 一.问题 问题代码: </pre><p><pre name="code" class="java">@Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub final ViewHolder holder

Android GridView布局设置

先来张效果图: layout布局设置: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent&quo

Swing Jtable 网格线设置

Swing jtable不绘制网格线或只绘制一条垂直或水平线问题总结 1 不绘制网格线…但占屏幕空间…网格是透明的…. myJTable1.setShowHorizontalLines(false); 水平线不显示 myJTable1.setShowVerticalLines(false); 垂直线不显示 2 不绘制网格线…并且不占屏幕空间…网格是没有的…. setIntercellSpacing():修改单元格间隔,因此也将影响网格线的粗细. setRowMargin (0);设置相邻两行单元

Dev gridView中设置自适应列宽和日期显示格式、金额的显示格式

在Dev GridView控件中,数据库中表数据日期都是长日期格式(yyyy-MM-dd HH:mm:ss),但显示在控件变成短日期格式(yyyy-MM-dd),金额显示要显示精确的数值, 比如80.00,90.15等,但在 dev gridView中只是显示80,90 1.解决日期显示问题的代码: 设置日期的displayformat,editFormat,EditMask /// <summary>        /// 设置时间显示格式        /// </summary&g

DevExpress GridView属性设置 z

本文主要总结控件的属性设置,附上图片,给大家一个参考.后续会给大家分享功能实现和使用的小技巧. GirdControl是数据的容器,它包含多种显示方式,GridView则是一种二维表格视图. 绑定数据源: List<Student> list = new List<Student>(); list.Add…… …… gridControl.DataSource = list; //注意这里是给gridControl绑定数据源而不是gridView 初始状态如下图: 属性设置: Vi

(转)DevExpress GridView属性设置

GirdControl是数据的容器,它包含多种显示方式,GridView则是一种二维表格视图. 绑定数据源: List<Student> list = new List<Student>(); list.Add…… …… gridControl.DataSource = list; //注意这里是给gridControl绑定数据源而不是gridView 初始状态如下图: 属性设置: Visual Studio设计进入”Run Designer”,可以打开属性设置的窗口. 1.Opt

Android GridView中设置了Button以后就不能响应OnItemClick()

当我们在GridView或者ListView里面设置了Textiew的时候,假如我们不给Textiew设置onlick()的话,那么Gridiew的OnItemClick()就是可以执行的,但是当把TextView换成是Button的时候我们也不设置onClick()的话,GridView的OnItemClick()也是不能执行的,为什么呢,这说明Button和TextView内部事件方面有区别,去查看Button的源代码,代码很少就这么几句 public class Button extend