Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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' ?

like image 982
Akshay Damle Avatar asked Jan 15 '14 17:01

Akshay Damle


1 Answers

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)

enter image description here

What is a Baseline?

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

What is a baseline

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

Warning

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

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.

like image 175
mrgnw Avatar answered Nov 20 '22 09:11

mrgnw