Saturday, March 11, 2017

android:gravity vs. android:layout_gravity

android:gravity vs. android:layout_gravity

The gravity attribute specifies how an object should be positioned along the X and Y axis inside its enclosing object. This may sound straightforward, but there's a catch: you'll encounter two different gravity attributes in Android. Although they look similar, they can actually yield very different results [Ref 2]:

    android:gravity: This positions the content that's inside a view, for example, the text inside a TextView


    android:layout_gravity: This positions a child view inside its parent container, for example, a TextView inside a LinearLayout




Copyright ©2017, Software Developer, All rights reserved.
See Contents

No comments:

Post a Comment