如何给gridview的单元格加上分割线

如何给gridview的单元格加上分割线,第1张

android:verticalSpacing="0dp"android:horizontalSpacing="0dp"然后每个Item给的图片 下面跟右边是有线的 左跟上面是没线的 这样也能看着粗吗

思路:修改第五行的样式,使第五行的下边框颜色为灰色,然后距离最下留15px的空白;修改第六行的样式,然后距离最上留15px的空白。这样看上去就像是每隔五行有一条空白数据作为分隔。

/* --- 数据行绑定 --- */

protected void XXX_RowDataBound(object sender, GridViewRowEventArgs e)

{

if (e.Row.RowType == DataControlRowType.DataRow)

{

/* --- 数据行为第五(倍数)或者第六(倍数)的时候 --- */

if (e.Row.RowIndex != 0 &&(e.Row.RowIndex % 4 == 0 || e.Row.RowIndex % 5 == 0))

{

foreach (TableCell cell in e.Row.Cells)

{

/* --- 添加样式 --- */

cell.Attributes.Add("style", e.Row.RowIndex % 4 == 0 ? "padding-bottom:15pxborder-bottom:solid 1px Gray" : "padding-top:15px")

}

}

}

}

找了个方法 item布局这样试试

<? xml version= "1.0" encoding= "utf-8" ?>

<LinearLayout xmlns:android= "url/apk/res/android"

android:layout_width= "match_parent"

android:layout_height= "match_parent"

android:background= "#c4c4c4"

android:orientation= "vertical"

android:padding= "1px" >

<LinearLayout

android:layout_width= "fill_parent"

android:layout_height= "fill_parent"

android:background= "@color/white"

android:gravity= "center"

android:orientation= "vertical" >

<ImageView

android:id= "@+id/homegriditem_iv"

android:layout_width= "100dp"

android:layout_height= "100dp"

android:src= "@drawable/ic_launcher" />

<TextView

android:id= "@+id/homegriditem_tv"

android:layout_width= "wrap_content"

android:layout_height= "wrap_content"

android:text ="xxx" />

</LinearLayout >

</ LinearLayout>


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11954084.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存