android:baselineAligned 设置子元素都按照基线对齐,默认是true
霍,完蛋,看着这个定义我懵了,必须得试一试,才能理解,话不多说,开撸代码吧!
注:此图片来源于其它博文。类似图片较多,找不到原出处,如有侵权,联系删除。
当android:baselineAligned="true"时候,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="true"
android:orientation="horizontal">
<TextView
android:id="@+id/view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:text="haosy" />
<TextView
android:id="@+id/view2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:textSize="30sp"
android:text="河南济源追梦孩"
/>
</LinearLayout>
效果如图
当android:baselineAligned="false"时候,
可以看到设置为false的时候基线不对齐,具体怎么定义,这在我看来不重要,实践出真知,只有自己动手试一试才能品出这细微差距。