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: 
I am created Listview instead of a menu.

This is my xml code

```
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/top_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".Dashbored">

<include
    android:id="@+id/tool_bar"
    layout="@layout/tool_bar">

</include>

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/tool_bar"
    android:elevation="7dp"
    android:fitsSystemWindows="true"
    tools:openDrawer="end">

    <LinearLayout
        android:id="@+id/linear_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <FrameLayout
            android:id="@+id/frame_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <include layout="@layout/f_home_screen" />

        </FrameLayout>

    </LinearLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:maxWidth="250dp"
        android:layout_gravity="end"
        android:background="#0284fe"
        android:fitsSystemWindows="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <include
                android:id="@+id/navheader"
                layout="@layout/nav_header" />

            <ListView
                android:id="@+id/lst_menu_items"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:divider="@null"
                android:dividerHeight="0dp"

                />
        </LinearLayout>

    </android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>

```

Then I used a custom adpater and textview , then I aligned my text gravity center.

This is my final output
[![This is my output](https://i.stack.imgur.com/d4SUN.png)](https://i.stack.imgur.com/d4SUN.png)
Try setting `android:layout_gravity="center_horizontal"` instead of `android:layout_gravity="end"` in your NavigationView.