Question: I have a numpy array (data.npy) which stores multiple sample images. I want to view/ save all the images. I have tried following:

```
img_array=np.load('data.npy')
i = 0
while i < len(img_array):
   plt.imshow(img_array[i], cmap='gray')
   plt.show()
   i += 1

```

but this gives an error: 

```
TypeError: Invalid dimensions for image data

```

Answer: 
Use `style="@style/MaterialAlertDialog.MaterialComponents.Title.Panel.CenterStacked"` attrib for navigation view as :

```
<com.google.android.material.navigation.NavigationView
            android:id="@+id/nav_view"
            android:layout_width="120dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:fitsSystemWindows="false"
            app:headerLayout="@layout/nav_header"
            app:menu="@menu/main_activity_navigator_items"
            android:background="@color/appbgcolor"
style="@style/MaterialAlertDialog.MaterialComponents.Title.Panel.CenterStacked"/>

```
`android:gravity="center"` sets the gravity of the content of the View its used on.
`android:layout_gravity` sets the gravity of the View or Layout in its parent.