imageview center of page android linearlayout code example

Example: how to put imageview in the center linearlayout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorPrimary"
    android:gravity="center_horizontal|center_vertical"
    android:orientation="vertical">

   <ImageView
        android:id="@+id/ivPic"
        android:layout_width="70dp"
        android:layout_height="70dp" />

</LinearLayout>

Tags:

Misc Example