Pr.Pg Next Pg

Analysis of main.xml tutorials

 

  • We can also align the text by using the gravity attribute.

  • Android:gravity sets the gravity (allignment) of the content of the View its used on.

  • Android:layout_gravity sets the gravity of the View or Layout in its parent.

  • These attribute can be set as follows

 

Constant

Value

Top

0x30

Bottom

0x50

Left

0x03

Right

0x05

center_vertical

0x10

fill_vertical

0x70

center_horizontal

0x01

fill_horizontal

0x07

Center

0x11

Fill

0x77

clip_vertical

0x80

clip_horizontal

0x08

Start

0x00800003

End

0x00800005

 

  • So after aligning the TextView with android:gravity=”center” we can see that the string “Hello Android!!!” has been aligned centrally with respect to horizontal as well as vertical axes.

 


Pr.Pg border                                              Next Pg