The function and baseline of LinearLayout attribute baselinealigned

Source: Internet
Author: User

I believe you are quite familiar with linearlayout, but do you know the properties of baselinealigned?

The official Android documentation describes this:

So what exactly is this property for?

baselinealigned: Baseline alignment.

The first thing to explain is the baseline, which is not common in Chinese, but is very common in other countries where the alphabet is written.

As shown, the red line is the baseline (baseline), is not very familiar with, this is we often write English in the four line of the third article.

What is the baselinealigned for? According to the official documentation, Baselinealigned is set to True by default, and when set to false,

The layout file and its child's baseline are not aligned.

Let's take an example to see what the effect is.

1 <linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" 2     xmlns:tools= "/http/ Schemas.android.com/tools "3     android:layout_width=" match_parent "4     android:layout_height=" Wrap_content "5     android:baselinealigned= "false" 6     android:orientation= "Horizontal" > 7  8     <textview 9         Android:layout_width= "Wrap_content" ten         android:layout_height= "Wrap_content"         android:layout_ marginright= "5dip"         android:text= "textview:p"/>13     <textview android:layout_width=         "wrap _content "         android:layout_height=" wrap_content "         android:layout_marginright=" 5dip "         android: Textsize= "30SP"         android:text= "largetextview:p"         />20 </LinearLayout>

This is when the baselinealigned value is set to False, that is, not aligned. Look at the running effect:

Change the baselinealigned value to true.

See, the difference is obvious, so it is good to understand the role of baselinealigned. In fact, this is not difficult, but I think whether it is difficult, as long as do not understand, you should think more, think about why.

The function and baseline of LinearLayout attribute baselinealigned

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.