Android implements a way to draw borders to Tablelayou _android

Source: Internet
Author: User

The example in this article describes how Android implements a border-drawing method for tablelayou. Share to everyone for your reference, specific as follows:

The effect is as follows:

idea : Use share as background display border

Steps :

1. Create table_frame_gray.xml files under the Res/drawable folder:

<?xml version= "1.0" encoding= "Utf-8"?> <shape xmlns:android=
"http://schemas.android.com/apk/res/" Android "
  android:shape=" Rectangle >
  <solid android:color= "#ffffff"/>
  <stroke
    Android:width= "0.01DP"
    android:color= "#848484"/>
</shape>

2. Refer to the Table_frame_gray.xml file as the background in the layout file:

<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 "Android: Background= "#FFFF00" android:paddingbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/ Activity_horizontal_margin "android:paddingright=" @dimen/activity_horizontal_margin "android:paddingtop=" @dimen Activity_vertical_margin "tools:context=".
    Mainactivity "> <tablelayout android:layout_width=" wrap_content "android:layout_height=" Wrap_content " Android:background= "#FF4000" android:stretchcolumns= "*" android:text= "@string/hello_world" > <!--micro-blog number > <TableRow> <linearlayout android:layout_width= "Wrap_content" android:layout_height
        = "Wrap_content" android:background= "@drawable/table_frame_gray" android:orientation= "vertical" > <textview andRoid:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:padding= "5DP" android:text= "232"/> <textview android:layout_width= "Wrap_content" Android:layout_heigh t= "Wrap_content" android:padding= "5DP" android:text= "Weibo"/> </LinearLayout> <! --Concern number--> <linearlayout android:layout_width= "wrap_content" android:layout_height= "Wrap_cont" Ent "android:background=" @drawable/table_frame_gray "android:orientation=" vertical "> <textv Iew android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:padding = "5DP" android:text= "/>" <textview android:layout_width= "Wrap_content" Andr oid:layout_height= "Wrap_content" android:padding= "5DP" android:text= "Attention"/> </linearlayout > <!--friends number--> <linearlayout android:layout_width= "wrap_content" android:layout_height= "Wrap_content"
          android:background= "@drawable/table_frame_gray" android:orientation= "vertical" > <textview
          Android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:padding= "5DP" android:text= "9"/> <textview android:layout_width= "Wrap_content" android:layout _height= "Wrap_content" android:padding= "5DP" android:text= "Fan"/> </LinearLayout> &

 Lt;/tablerow> </TableLayout> </RelativeLayout>

For more information on Android-related content readers can view the site topics: "Android Debugging techniques and common problems solution summary", "Android Development introduction and Advanced Course", "Android Multimedia operating skills Summary (audio, video, recording, etc.)", " Android Basic Components Usage Summary, Android View tips Summary, Android layout layout tips and Android Control usage summary

I hope this article will help you with the Android program.

Related Article

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.