I\'ve got a linear layout and an image...
Here are 2 ways you can center an image (or images) both vertically and horizontally in LinearLayout.
(1) Use the android:layout_gravity="center" attribute in ImageView
How this works: the android:layout_gravity="center" attribute in ImageView centers itself (i.e. the image) vertically and horizontally relative to its parent (LinearLayout).
-- OR --
(2) Alternatively, you can use the android:gravity="center" attribute in LinearLayout and omit the android:layout_gravity="center" attribute in ImageView :
How this works: the android:gravity="center" attribute in LinearLayout centers its child/children (in this case, it's the image) vertically and horizontally.