如何向线性布局添加标题

5

我需要创建一个如下所示的GUI界面。我已经使用LinearLayout并创建了周围的边框。我需要在边框之间插入标题文本。有什么好的方法可以实现吗?enter image description here

3个回答

3
<RelativeLayout>)
    <LinearLayout with border>
    <TextView with white background>
</RelativeLayout>

TextView 应该出现在覆盖边框的 LinearLayout 上方,带有它的白色背景。你可以使用边距来定位它。


1

使用相对布局作为父布局,并将所有线性布局代码放在相对布局下面。然后在相对布局中添加TextView,并指定该TextView位于顶部并给予边距。

  <RelativeLayout>
     <TextView android:layout_alignParentTop="true"
      android:layout_margin="20dip/>
     <LinearLayout>
                // here is your linear layout
     </LinearLayout>
   </RelativeLayout>

0
使用RelativeLayout可以重叠线条,而在LinearLayout上无法实现。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接