Gridview gridline settings

Source: Internet
Author: User

Today, I want to use grid layout to display products in online shopping malls, but I always feel that it is not easy to use it, so I want to add a gridline to it, but I have encountered a problem, grid layout is actually very simple. It is to set the background color of the gridview layout and the layout referenced by the adapter to set the background color. My settings are as follows:

 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 = "Haier 1.5 fluorine-free air conditioner with Variable Frequency wall-mounted air conditioner" 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 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 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 off" Android: textcolor = "# ffff2e2e" Android: textsize = "12sp"/> <textview Android: Id = "@ + ID/TV _group_detail" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_marginleft = "8dp" Android: ellipsize = "end" Android: singleline = "true" Android: TEXT = "0 items purchased" Android: textcolor = "@ Android: color/darker_gray" Android: textsize = "12sp"/> </linearlayout> </relativelayout> </linearlayout>

The result is as follows:



I circled the four sides. What do you think is ugly? Anyway, I think it is ugly, this can be tangled, and finally find a solution, so easy... is to add such an attribute in the gridview layout:

Android: listselector = "@ null"

The display effect is as follows:



How is it? Is it awesome?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.