什么是RelativeLayout的底线? [英] What is the baseline in RelativeLayout?

查看:213
本文介绍了什么是RelativeLayout的底线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是底线是指在一个相对布局的情况下使用时?简单的问题,很可能,但文档和谷歌提供任何线索。

What does "baseline" refer to when used in the context of a relative layout? Simple question, probably, but the documentation and google offer no hints.

推荐答案

术语基线来自排版。它在文本中的无形的线封坐。

The term baseline comes from typography. It's the invisible line letters in text sit on.

例如,假设你把两个的TextView 元素彼此相邻。你给第二个的TextView 大的填充(比如20dp)。如果添加 layout_alignBaseline 的第二个元素,将文本就跑了,以配合第一个元素的基线。从两个元素的文本将出现,如果他们写在同一个无形的线。

For example, imagine you put two TextView elements next to each other. You give the second TextView a big padding (say 20dp). If you add layout_alignBaseline to the second element, the text will "scoot up" to align with the baseline of the first element. The text from both elements will appear as if they were written on the same invisible line.

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
  <TextView
      android:id="@+id/text1"
      android:text="aatlg"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      />
  <TextView
      android:text="joof"
      android:background="#00ff00"
      android:padding="20dp"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_toRightOf="@id/text1"
      android:layout_alignBaseline="@id/text1"
      />
</RelativeLayout>

这篇关于什么是RelativeLayout的底线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆