对于可以显示文字的View(如TextView,Button等),它的baseline 指的是这个UI控件中文字Text的baseline 到UI控件顶端的偏移值,可以通过View 的getBaseline()返回,如果一个View不支持baseline 对齐(比如ImageView) getBaseline()返回-1.

LinearLayout 带有一个属性android:baselineAligned 其缺省为true,也就是当使用android:orientation 为horizontal ,其子View的baseline 是对齐的,表现在不同View显示的文字的baseline是对齐的。

如本例: 在顶部显示 TextView, Button ,TextView 文字的基准线(baseline)是对齐的。

可以将android:baselineAligned 设为false 做个比较:

<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”horizontal”
android:baselineAligned=”false”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”>

<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginRight=”3dip”
android:text=”@string/baseline_1_label” />

<Button
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginRight=”3dip”
android:text=”@string/baseline_1_button” />

<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:textSize=”20sp”
android:text=”@string/baseline_1_bigger” />

</LinearLayout>

最新文章

  1. phpunit测试学习 1:一点简单的扼要有用的东西的总结 一点入门认识
  2. 查看Visual Studio异常内容
  3. webservice入门(1)
  4. C#调用有有参有返的存储过程
  5. web页面实现指定区域打印功能
  6. 从topcoder赚钱的方法
  7. RouterOS软路由常用命令
  8. 新浪微博sdk bug
  9. 【iOS UISearchBar父控件是UIScrollView时,上移的问题】
  10. COUNT()函数的使用
  11. PHP MySQL Update 之 Update
  12. 关于EL表达式的生效时间(猜想)
  13. jQuery实例2
  14. linux网卡配置
  15. Android简易实战教程--第三十四话《 自定义SeekBar以及里面的一些小知识》
  16. hibernate框架(2)---Hibernate的核心API
  17. vue动态class——实现tag的选中状态
  18. 关于SQL Server将一列的多行内容拼接成一行,合并显示在另外表中
  19. VUE2 第五天学习--过渡效果
  20. IntelliJ IDEA连接TFS local workspace无法正常签入

热门文章

  1. Redis相关指令文档
  2. No bean named &#39;sessionFactory&#39; is defined
  3. QueryError:Incorrect result size: expected 1, actual 0
  4. C# 图解教程 第二章 C#编程概述
  5. 【Luogu1291】百事世界杯之旅(动态规划,数学期望)
  6. bzoj2157
  7. Couldn&#39;t save uncommitted changes.
  8. 极重要基础命令三剑客加find
  9. 【noip模拟】2048
  10. 进入TP-Link路由器之后利用快捷键F12查看星号路由密码的方法