Android-gridview adding grid split lines

Source: Internet
Author: User

To set the divider in the ListView, add the following parameters:
android:divider= "@color/gray"
android:dividerheight= "1DP"

GridView Grid Layout, which by default is not a grid line

Find an online profile and find a way to add gridlines to the GridView

In fact, the grid line is implemented by setting the interval of the GridView subkeys and setting the GridView background color and the child background color, respectively.

Implementation method

    1. Sets the GridView background color, sets the horizontal inter-directional interval property value android:horizontalspacing, and the vertical direction interval property value android:verticalspacing
    2. Set the GridView subkey background color

Example code:
1.main.xml

<GridView Android:id= "@+id/gv_words"android:visibility= "Gone"Android:background= "@color/gray"Android:columnwidth= "60DP"Android:numcolumns= "5"Android:listselector= "@null"android:verticalspacing= "1.0px"android:horizontalspacing= "1.0px"android:soundeffectsenabled= "true"Android:smoothscrollbar= "true"Android:stretchmode= "ColumnWidth"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"Android:layout_above= "@+id/llayout2"Android:layout_below= "@+id/llayout1"/>


2.GrivViewItem layout

<?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= "@color/white" > <relativelayout android:layout_width= "50DP"Android:layout_height= "50DP"Android:layout_margin= "5DP" > <TextView Android:id= "@+id/gv_bushou_textview1"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_below= "@+id/itemimage"Android:layout_margin= "1DP"Android:layout_alignparenttop= "true"Android:layout_alignparentleft= "true"Android:layout_above= "@+id/gv_bushou_textview2"Android:layout_toleftof= "@+id/gv_bushou_textview2"android:textsize= "25DP"Android:textcolor= "@color/blue"Android:text= "difficult" > </TextView> <TextView Android:id= "@+id/gv_bushou_textview2"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_below= "@+id/itemimage"Android:layout_alignparentbottom= "true"Android:layout_alignparentright= "true"Android:textcolor= "@color/gray"android:textsize= "10DP"Android:text= "1 strokes" > </TextView> </RelativeLayout></LinearLayout>

3. Running

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.