What's the difference between alignBaseline and alignBottom in Android?

左心房为你撑大大i 提交于 2019-11-27 11:10:40

问题


I tried both to align a few TextView objects and they gave me the same results. What exactly is the difference between 'baseline' and 'bottom' ?


回答1:


To visualize the difference, I usually imagine two textboxes in Word or Photoshop.

  • alignBottom lines up the bottom of the textboxes. (The blue outline)
    • Text could be uneven, but the boxes they're in would line up on the bottom.
  • alignBaseline aligns the actual text within the box. This can help ensure that the texts line up on the bottom, regardless of font size or textbox size. (The green line)

What is a Baseline?

Baseline is a typography term that refers to the invisible line text is written on.

(As referenced in What is the baseline in RelativeLayout?)

Warning

If you're not careful, using alignBaseline could make your layout look like this:

Details: Watch That Baseline Alignment

I don't know if you're still looking for the answer, but I decided to at least put this out there since this was one of the first results.



来源:https://stackoverflow.com/questions/21144227/whats-the-difference-between-alignbaseline-and-alignbottom-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!