您的位置:首页 > 移动开发 > Android开发

Android 布局学习之——LinearLayout属性baselineAligned的作用及baseline

2018-01-11 16:38 351 查看
相信大家对LinearLayout已经相当熟悉,但你们是否了解它的属性baselineAligned呢?

  那到底这个属性是做什么用的呢?

         baselineAligned:基准线对齐。

     首先要解释什么是基准线,这个在中文中不常见,但在以字母为书写语言的其他国家非常常见。



  那baselineAligned是做什么用的呢?根据官方文档,baselineAligned默认设置为true,当设置为false时,

      布局文件和它的孩子的基准线不对齐。

      让我们通过一个例子来看看效果怎样的。
<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"
10         android:layout_height="wrap_content"
11         android:layout_marginRight="5dip"
12         android:text="TextView:p" />
13     <TextView
14         android:layout_width="wrap_content"
15         android:layout_height="wrap_content"
16         android:layout_marginRight="5dip"
17         android:textSize="30sp"
18         android:text="LargeTextView:p"
19         />
20 </LinearLayout>






 看,差别明显,这样就很好的理解了baselineAligned的作用了。其实,这个并不难,但我觉得不管难不难,只要不明白,就应该多思考,想想为什么。
 

原文链接:http://www.cnblogs.com/JohnTsai/p/4074643.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: