Issue
I am using NavigationView from the android.support.design
library.
I want to make it's menu be vertically centered.
So, instead of the default alignement...
src="https://i.stack.imgur.com/sXXMc.png" alt="enter image description here">
... I want it to look something like this:
From what I could see there are no layout attributes in NavigationView
that would help me achieve this. I tried with android:foregroundGravity="center_vertical"
but had no luck.
Does anybody know of a way to solve this without having to change NvigationView
for a different layout?
Solution
It doesn't look like this is possible without creating a custom NavigationView.
However, because NavigationView is a SubClass of FrameLayout; you can add your own Views into it.
You could therefore not set menu items but add your own ListView (setting android:layout_gravity="center_vertical"
).
Obviously you would then need to implement a ListAdapter and cannot use OnNavigationItemSelectedListener which is not ideal.
Answered By - Robbie188
Answer Checked By - David Marino (JavaFixing Volunteer)