本例将一个TextView 和父RelativeLayout 左,上对齐,然后就另一个View和它设置baseline对齐:
<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”match_parent”
android:layout_height=”match_parent”>
<TextView android:id=”@+id/anchor”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_alignParentTop=”true”
android:layout_alignParentLeft=”true”
android:textStyle=”bold”
android:text=”@string/baseline_7_fat” />
<TextView
android:layout_width=”wrap_content”
android:layout_alignParentRight=”true”
android:layout_alignBaseline=”@id/anchor”
android:layout_height=”wrap_content”
android:text=”@string/baseline_7_lean” />
本文介绍了一个简单的XML布局示例,展示了如何使用RelativeLayout实现两个TextView的基线对齐。其中一个TextView固定在左上角,另一个则与其基线对齐。

2万+

被折叠的 条评论
为什么被折叠?



