Textview of Android uniform coverage Interface

Source: Internet
Author: User

Sometimes, the average distribution of five textviews on the page is desired. To facilitate future use, you can write your own code as a blog to facilitate future use. The principle is to use relative layout outside the page, first, determine the first (layout_alignparenttop), third (layout_centerinparent), and fifth (layout_alignparentbottom), and then determine the second position (below the first, on the top of the third node), but if you write this statement, you will find that the second node is close to the first node, while the third node is far away, therefore, set a large relativelayout (fill_parent in width and height) outside the second layout, and then place the second one in the middle of the layout, similarly to the fourth.

Code:

<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"> <textview Android: id = "@ + ID/mmainfirst" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_alignparenttop = "true" Android: layout_centerhorizontal = "true" Android: padding = "@ dimen/padding_medium" Android: Background = "@ drawable/ic_launcher" Android: text = "first line" tools: context = ". mainactivity "/> <textview Android: Id =" @ + ID/mmainthird "Android: layout_width =" wrap_content "Android: layout_height =" wrap_content "Android: layout_centerinparent =" true "Android: padding = "@ dimen/padding_medium" Android: Background = "@ drawable/ic_launcher" Android: text = "Row 3" tools: context = ". mainactivity "/> <textview Android: Id =" @ + ID/mmainfifth "Android: layout_width =" wrap_content "Android: layout_height =" wrap_content "Android: layout_alignparentbottom =" true "Android: layout_centerhorizontal = "true" Android: padding = "@ dimen/padding_medium" Android: Background = "@ drawable/ic_launcher" Android: text = "" tools: context = ". mainactivity "/> <relativelayout Android: layout_width =" fill_parent "Android: layout_height =" fill_parent "Android: layout_below =" @ ID/mmainfirst "Android: layout_above = "@ ID/mmainthird"> <textview Android: Id = "@ + ID/mmainsecond" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_centerinparent = "true" Android: padding = "@ dimen/padding_medium" Android: Background = "@ drawable/ic_launcher" Android: text = "second line" tools: context = ". mainactivity "/> </relativelayout> <relativelayout Android: layout_width =" fill_parent "Android: layout_height =" fill_parent "Android: layout_below =" @ ID/mmainthird "Android: layout_above = "@ ID/mmainfifth"> <textview Android: Id = "@ + ID/mmainfourth" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_centerinparent = "true" Android: padding = "@ dimen/padding_medium" Android: Background = "@ drawable/ic_launcher" Android: text = "Row 4" tools: context = ". mainactivity "/> </relativelayout>

Effect:

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.