Android Table Layout settings border

Source: Internet
Author: User

The Android table layout itself has no border, but the background color can be used to display the table borders.

You can first set the background color of the TableRow, and then set the back color of the content. A border appears based on their color difference. Just fine-tune the margin and pading properties of content with TableRow!

The process of tuning is really annoying! Next time don't do this kind of work ~ whining! Uncomfortable!

Paste the Layout code:

<Relativelayoutxmlns: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"Android:background= "@color/white" >    <includeLayout= "@layout/titlebar_home" />    <TablelayoutAndroid:id= "@+id/table1"Android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"Android:layout_margintop= "50DP"android:padding= "6.5dip" >        <TableRowAndroid:background= "@color/jiemianbiankuang"android:orientation= "Horizontal"Android:paddingleft= "0.5dip"Android:paddingright= "0.5dip"Android:paddingtop= "1dip" >            <ImageButtonAndroid:id= "@+id/imageviewmsg"Android:layout_width= "100DP"Android:layout_height= "100DP"android:layout_gravity= "Center_vertical"Android:layout_marginbottom= "0.5dip"Android:layout_marginleft= "0.5dip"Android:background= "@color/white"android:contentdescription= "@string/messagecenter"android:src= "@drawable/msg" />            <ImageButtonAndroid:id= "@+id/imageview1"Android:layout_width= "100DP"Android:layout_height= "100DP"android:layout_gravity= "Center_vertical"Android:layout_marginbottom= "0.5dip"Android:layout_marginleft= "0.5dip"Android:background= "@color/white"android:src= "@drawable/book" />            <ImageButtonAndroid:id= "@+id/imageview2"Android:layout_width= "100DP"Android:layout_height= "100DP"android:layout_gravity= "Center_vertical"Android:layout_marginbottom= "0.5dip"Android:layout_marginleft= "0.5dip"Android:background= "@color/white"android:src= "@drawable/maozi" />        </TableRow>        <TableRowAndroid:background= "@color/jiemianbiankuang"android:orientation= "Horizontal"Android:paddingleft= "0.5dip"Android:paddingright= "0.5dip"Android:paddingtop= "0dip" >            <ImageButtonAndroid:id= "@+id/imageview4"Android:layout_width= "100DP"Android:layout_height= "100DP"android:layout_gravity= "Center_vertical"Android:layout_marginbottom= "0.5dip"Android:layout_marginleft= "0.5dip"Android:background= "@color/white"android:src= "@drawable/earth" />            <ImageButtonAndroid:id= "@+id/imageview5"Android:layout_width= "100DP"Android:layout_height= "100DP"android:layout_gravity= "Center_vertical"Android:layout_marginbottom= "0.5dip"Android:layout_marginleft= "0.5dip"Android:background= "@color/white"android:src= "@drawable/unno" />            <ImageButtonAndroid:id= "@+id/imageview6"Android:layout_width= "100DP"Android:layout_height= "100DP"android:layout_gravity= "Center_vertical"Android:layout_marginbottom= "0.5dip"Android:layout_marginleft= "0.5dip"Android:background= "@color/white"android:src= "@drawable/zuoye" />        </TableRow>    </Tablelayout></Relativelayout>

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.