Checking out the gravity attribute

View Gravity:

  • gravity (direction of the content inside the view): This accepts the following--top, left, right, start, end, center, center_horizontal, center_vertical, and many other
  • layout_gravity (direction of the content inside the view parent): This accepts the following--top, left, right, left, start, end, center, center_horizontal, center_vertical, and many others

It's possible to combine values for gravity as follows:

    android:gravity="top|center_horizontal" 

Get Mastering Android Development with Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.