What is the baseline in Android:relativelayout?

Source: Internet
Author: User

reprinted from: Http://www.cnblogs.com/loulijun/archive/2012/10/17/2727580.html

Chinese translation is the meaning of the baseline, seemingly simple and some difficult to understand, in fact, this baseline equivalent to write text in the notebook at the bottom of the line, in the relativelayout baseline example:

For example, add two adjacent TextView, give the second TextView a larger padding (such as 20DP), if added layout_alignbaseline to the second TextView, the text in TextView " World "will be at the same level as" Hello "in the first TextView, and the second TextView control is moved up, as if" Hello "and" world "are on the same line, and if there is no add layout_alignbaseline, specifically see below

<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/text1"        android:text= "Hello"        android:background= "#aa0000"        android:layout_width= "wrap_content"        android:layout_height= "wrap_content"        />            <textview            android:text= "World"            android:background= "#00ff00"            android:padding= "20DP"            android:layout_ Width= "Wrap_content"            android:layout_height= "wrap_content"            android:layout_torightof= "@id/text1"            Android:layout_alignbaseline= "@id/text1"            /></relativelayout>

1: Not added Layout_alignbaseline

2: Add Layout_alignbaseline, like two lines of text Hello World written on a line

3: Test the vertical aspect, set the second TextView to the Layout_below property, without adding a layout_alignbaseline

4, test the vertical aspect, the second TextView set to the Layout_below property, plus layout_alignbaseline. As you can see, it overrides the above control, but it's not centered vertically.

What is the baseline in Android: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.