As you can see the custom layout is at the right and after some research I found that the blank space is reserved for icon and text of item. Is there a way to remove that blank space and align the custom layout to the left?
I am using menu to fill the navigation view as shown below:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.NavigationView
android:id="#+id/nav1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/nav_header"
app:menu="#menu/nav_drawer_items"
app:itemBackground="#color/app_bg_color"
app:itemIconTint="#color/text_white"
app:itemTextColor="#color/text_white"
android:background="#color/bottom_navigation_color"
android:fitsSystemWindows="true"
android:theme="#style/NavigationView" />
</android.support.v4.widget.DrawerLayout>
nav_drawer_items
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/tabs"
android:title="MAIN">
<menu>
<item
android:id="#+id/nav_highlights"
android:icon="#drawable/icon_home"
android:title="#string/nav_home"
android:checkable="true"/>
<item
android:id="#+id/nav_movies"
android:icon="#drawable/icon_movie"
android:title="#string/nav_movies"
android:checkable="true"/>
<item
android:id="#+id/nav_originals"
android:icon="#drawable/icon_original"
android:title="#string/nav_originals"
android:checkable="true"/>
<item
android:id="#+id/nav_live_tv"
android:icon="#drawable/icon_live"
android:title="#string/nav_live_tv"
android:checkable="true"/>
</menu>
</item>
<item
android:id="#+id/support"
android:title="SUPPORT">
<menu>
<item
android:id="#+id/nav_about_us"
android:icon="#drawable/icon_about"
android:title="#string/nav_about_us"
android:checkable="true"/>
<item
android:id="#+id/nav_feedback"
android:icon="#drawable/icon_feedback"
android:title="#string/nav_feedback"
android:checkable="true"/>
<item
android:id="#+id/nav_setting"
android:icon="#drawable/icon_setting"
android:title="#string/nav_setting"
android:checkable="true"/>
<item
android:id="#+id/nav_logout"
android:icon="#drawable/icon_logout"
android:title="#string/nav_logout"
android:checkable="true"/>
</menu>
</item>
<item
android:id="#+id/connect_us"
android:title="Connect with us">
<menu>
<item
android:id="#+id/social_items"
android:checkable="true"
app:showAsAction="always"
android:title=""
app:actionLayout="#layout/connect_us"/>
</menu>
</item>
</menu>
In menu you can see that I am using a layout using app:actionLayout in last item. Here is the connect_us.xml
<?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/app_bg_color"
android:orientation="horizontal"
android:gravity="start">
<ImageView
android:id="#+id/connect_youtube"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/youtube_icon"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:padding="5dp" />
<ImageView
android:id="#+id/connect_facebook"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/facebook_icon"
android:padding="5dp"/>
<ImageView
android:id="#+id/connect_twitter"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/twitter_icon"
android:padding="5dp"/>
</LinearLayout>
Change your code according to my , its working . Take RelativeLayout as parent (only change with your connect_us.xml):
connect_us.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FFFFFF"
android:gravity="left">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/connect_youtube"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#mipmap/ic_launcher"
android:padding="5dp" />
<ImageView
android:id="#+id/connect_facebook"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#mipmap/ic_launcher"
android:padding="5dp"/>
<ImageView
android:id="#+id/connect_twitter"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#mipmap/ic_launcher"
android:padding="5dp"/>
</LinearLayout>
</RelativeLayout>
Second Solution :
In your main_activity.xml (fix the width of the Navigation drawer)
I used here
android.support.design.widget.NavigationView to android:layout_width="320dp" I know its not a proper solution to fix layout_width.
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer"
/>
And connect_us.xml layout also set the layout_width = "320dp"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="320dp"
android:layout_height="match_parent"
android:background="#color/app_bg_color"
android:orientation="horizontal"
android:gravity="start">
<ImageView
android:id="#+id/connect_youtube"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/youtube_icon"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:padding="5dp" />
<ImageView
android:id="#+id/connect_facebook"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/facebook_icon"
android:padding="5dp"/>
<ImageView
android:id="#+id/connect_twitter"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/twitter_icon"
android:padding="5dp"/>
</LinearLayout>
Try adding your navigation view and Custom Layout (connect_us) inside a NestedScrollView as below:-
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.NavigationView
android:id="#+id/nav1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:background="#color/bottom_navigation_color"
android:fitsSystemWindows="true"
android:theme="#style/NavigationView"
app:headerLayout="#layout/nav_header"
app:itemBackground="#color/app_bg_color"
app:itemIconTint="#color/text_white"
app:itemTextColor="#color/text_white"
app:menu="#menu/nav_drawer_items" />
<include
android:id="#+id/footer_layout"
layout="#layout/connect_us"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.DrawerLayout>
Also, make sure to disable Nested Scrolling of NavigationView's child as below:-
ViewCompat.setNestedScrollingEnabled(navigationView.getChildAt(0), false);
I got a solution for this use recyclerview and inside your navigation view and add your views to recyclerview and create your adapter :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/my"
layout="#layout/nav_header_main" />
<android.support.v7.widget.RecyclerView
android:id="#+id/rvNavMenu"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:layout_weight="7"
android:overScrollMode="never" />
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
Related
For example,I want a 500dp and a 150dp TextView inside a LinearLayout. For responsive layout, at their middle, there would be a red area if there is any remaining height (e.g.:at large screen device):
Large Screen:
and if there is no remain space (e.g.:at small screen device), there would be no red area and the view become scrollable:
Small Screen:
I tried:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:background="#FFFFAA"
android:layout_width="match_parent"
android:layout_height="500dp"
android:text="500dp"
android:gravity="center_vertical"
android:textAlignment="center" />
<View
android:background="#FF0000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:background="#AAFF"
android:layout_width="match_parent"
android:layout_height="150dp"
android:text="150dp"
android:gravity="center_vertical"
android:textAlignment="center" />
</LinearLayout>
</ScrollView>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
which set layout_weight="1" for the red area, but the red area does not fill the remaining height at large screen:
Large screen:
How can I do that?
make your scrollview like this
use android:fillViewport="true" because it Defines whether the scrollview should stretch its content to fill the viewport.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:background="#FFFFAA"
android:layout_width="match_parent"
android:layout_height="500dp"
android:text="500dp"
android:gravity="center_vertical"
android:textAlignment="center" />
<View
android:background="#FF0000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:background="#AAFF"
android:layout_width="match_parent"
android:layout_height="150dp"
android:text="150dp"
android:gravity="center_vertical"
android:textAlignment="center" />
</LinearLayout>
</ScrollView>
You should set android:fillViewport="true" on ScrollView. This will stretch content to the height of scroll view if necessary.
You should use fixed footer
Something like this:-
<android.support.design.widget.NavigationView
android:id="#+id/drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/drawer_header"
app:menu="#menu/drawer">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:clickable="true"
android:orientation="vertical">
<TextView
android:id="#+id/footer_item_1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center"
android:text="Footer Item 1" />
<TextView
android:id="#+id/footer_item_2"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center"
android:text="Footer Item 2" />
</LinearLayout>
And res/menu/drawer.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group>
<item
android:id="#+id/nav_item_1"
android:icon="#drawable/ic_nav_item_1"
android:title="Nav Item 1" />
<item
android:id="#+id/nav_item_2"
android:icon="#drawable/ic_nav_item_2"
android:title="Nav Item 2" />
<item
android:id="#+id/nav_item_3"
android:icon="#drawable/ic_nav_item_3"
android:title="Nav Item 3" />
<item
android:id="#+id/nav_item_4"
android:icon="#drawable/ic_nav_item_4"
android:title="Nav Item 4" />
<item
android:id="#+id/footer_spacer_1"
android:checkable="false"
android:enabled="false"
android:orderInCategory="200"
android:title="" />
<item
android:id="#+id/footer_spacer_2"
android:checkable="false"
android:enabled="false"
android:orderInCategory="200"
android:title="" />
</group>
</menu>
I have the following Navigation Drawer menu setup:
Main layout activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="150dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/colorPrimaryDark"
android:fitsSystemWindows="true"
android:theme="#style/NavigationViewStyle"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" >
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
My menu activity_main_drawer.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="#+id/nav_profile"
app:actionLayout="#layout/menu_item"
android:title=""/>
</menu>
Menu item menu_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:src="#drawable/menu_icon"
android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Menu Title"
android:textSize="16sp"
android:textColor="#color/white"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
The result I get is this:
Result i am getting
Instead I want it to be horizontally centered, what did I do wrong here? I have tried many fixes with the custom layout's gravity (menu_item.xml) as well as the items, nothing seems to work.
I don't know if the app:actionLayout in the menu can be centered or not at all, if not please tell me what is the correct way to make an item like that with the alignment I want.
Thanks in advance.
Try this for the
menu_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<ImageView
android:id="#+id/image_view"
android:layout_width="match_parent"
android:layout_height="75dp"
android:layout_gravity="center|center_horizontal"
android:src="#drawable/menu_icon" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/image_view"
android:layout_gravity="center_horizontal|center"
android:gravity="center"
android:text="Menu Title"
android:textColor="#color/white"
android:textSize="16sp" />
</RelativeLayout>
Hope this helps
Try this, menu_item.xml you can set gravity to center_horizontal.
I am trying to make a custom Navigation Drawer with images and title underneath, like in the following image;
So this is my layout I named: menu_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<ImageView
android:id="#+id/img_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/menu_icon"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Menu Title"
android:gravity="center"
android:textSize="16dp"
android:textColor="#color/white"
android:layout_below="#+id/img_menu"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
my activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/colorPrimaryDark"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
and finally the menu; activity_main_drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="#+id/nav_profile"
app:actionLayout="#layout/menu_item"/>
</menu>
The result I get is missing the TextView, what could be the issue here?
my result:
Thanks
use simple LinearLayout and apply android:gravity="center" to the root layout. also remove parent margin android:layout_margin="10dp"
the textview is out of the viewport in menu items
try this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/img_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Menu Title"
android:textColor="#000000"
android:textSize="16sp" />
</LinearLayout>
Hello guys I have problem with NavigationBarView. I set NavigationBarView this without not swipe and I set Other view above NavigationBarView. I made this Activity with Tranculents Style. But I have got error, the notification bar is double, this drawed on top NavigationBarView.
This my XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ad.sample.ui.activity.HomeActivity">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
</fragment>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btn_main_menu"
android:layout_alignBottom="#+id/navigation_view"
android:background="#color/biru"
android:layout_alignParentTop="true"
android:clickable="true"
android:soundEffectsEnabled="false" />
<android.support.design.widget.NavigationView
android:paddingLeft="8dp"
android:id="#+id/navigation_view"
android:layout_below="#+id/btn_main_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/biru"
app:itemTextColor="#color/white"
app:menu="#menu/main_menu" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/btn_main_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="#dimen/marginTopToolbar"
app:backgroundTint="#color/white"
app:elevation="1dp" />
</RelativeLayout>
</FrameLayout>
And this Style-v21
<style name="AppTheme.HomeActivity">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
How to fix it?
Try this:- your code is working fine in mine case , looks like the problem of double notification bar is due to some other reason. But i have rectified your code.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ad.sample.ui.activity.HomeActivity">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
</fragment>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_above="#+id/btn_main_menu"
android:background="#color/blue"
android:clickable="true"
android:soundEffectsEnabled="false" />
<android.support.design.widget.NavigationView
android:paddingLeft="8dp"
android:id="#+id/navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/blue"
app:itemTextColor="#color/white"
app:menu="#menu/main_menu"
android:layout_alignParentBottom="true"
/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/btn_main_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
app:backgroundTint="#color/white"
app:elevation="1dp"
android:layout_above="#+id/navigation_view"/>
</RelativeLayout>
</FrameLayout>
I need to have to have a text view after my menu items, it shouldn't be responsive. I needn't update it programmatically. I'm using a navigation drawer activity. I could create an image out of the text so implementation of image view will help as well.
Kind of like this
I don't know you use which code and version to make navigation menu. but I have 3 suggestions for you.
one of them is below code if you use 'android.support.design.widget.NavigationView' :
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.NavigationView
android:id="#+id/navigation"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
app:menu="#menu/menu_drawer">
</android.support.design.widget.NavigationView>
<TextView
android:id="#+id/textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="your Sentences" />
</LinearLayout>
another is below code, if you use android.support.v4.widget.DrawerLayout :
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="#+id/content_frame"...../>
<RelativeLayout
android:id="#+id/relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start" >
<ListView
android:id="#+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<TextView
android:id="#+id/text_view1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Your Sentences" />
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
and last suggestion is that you use different list item in your menu. use getViewTypeCount() and getItemViewType(int position) in your adapter. see this link
<group
android:id="#+id/first"
android:checkableBehavior="single">
<item
android:id="#+id/item_1"
android:icon="#drawable/ic_feed_grey_500_24dp"
android:title="Feed" />
<item
android:id="#+id/item_2"
android:icon="#drawable/ic_explore_grey_500_24dp"
android:title="Explore" />
<item
android:id="#+id/item_4"
android:icon="#drawable/ic_settings_grey_500_24dp"
android:title="Settings" />
</group>
<group
android:id="#+id/second"
android:checkableBehavior="single">
<item xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/navi_item_text_layout"
android:title="Your text layout"
app:actionLayout="#layout/text_layout"
app:showAsAction="always" />
</group>
I suppose you already have navigation_view.xml ?
I tried using Linear layout,Frame layout,etc. but they didn't have scroll-able behavior. Using group items didn't give the flexibility I wanted for the text view. I got this solution from another answer.
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header"
app:menu="#menu/activity_nav_drawer__main_drawer">
<android.support.design.widget.NavigationView
android:id="#+id/navigation_drawer_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:headerLayout="#layout/nav_footer"/>
</android.support.design.widget.NavigationView>
Aligning another nested navigation view to the bottom and giving it it's own header will have it aligned to the bottom and you can place imageviews or text views in it.
You can try this way.. I am posting details code which might help you
1)This is main class where navigation drawer appears
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!--<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer"
android:background="#color/app_blue"
app:itemIconTint="#color/app_white"
app:itemTextColor="#color/app_white">
</android.support.design.widget.NavigationView>-->
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="#menu/activity_main_drawer"
android:background="#color/app_blue"
app:itemIconTint="#color/app_white"
app:itemTextColor="#color/app_white">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
app:elevation="0dp"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer"
android:background="#color/app_blue"
app:itemIconTint="#color/app_white"
app:itemTextColor="#color/app_white">
></android.support.design.widget.NavigationView>
<LinearLayout
android:id="#+id/spacer_to_bottom"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="0dp"
android:layout_weight="1"/>
<include layout="#layout/nav_footer_main"></include>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
2)this is menu xml class
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_home"
android:icon="#drawable/ic_menu_camera"
android:title="#string/menu_home" />
<item
android:id="#+id/nav_reg_log"
android:icon="#drawable/ic_menu_gallery"
android:title="#string/menu_reg_log" />
<item
android:id="#+id/nav_profile"
android:icon="#drawable/ic_menu_slideshow"
android:title="#string/menu_profile" />
<item
android:id="#+id/nav_notification"
android:icon="#drawable/ic_menu_manage"
android:title="#string/menu_notificatio" />
<item
android:id="#+id/nav_post_offer"
android:icon="#drawable/ic_menu_manage"
android:title="#string/menu_post_offer" />
<item
android:id="#+id/nav_history"
android:icon="#drawable/ic_menu_manage"
android:title="#string/menu_history" />
<item
android:id="#+id/nav_review"
android:icon="#drawable/ic_menu_manage"
android:title="#string/menu_review" />
<item
android:id="#+id/nav_blog"
android:icon="#drawable/ic_menu_manage"
android:title="#string/menu_blog" />
</group>
<!--<item android:title="Communicate">
<menu>
<item
android:id="#+id/nav_share"
android:icon="#drawable/ic_menu_share"
android:title="Share" />
<item
android:id="#+id/nav_send"
android:icon="#drawable/ic_menu_send"
android:title="Send" />
</menu>
</item>-->
</menu>
3)this is footer xml class
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/app_blue"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:theme="#style/ThemeOverlay.AppCompat.Dark">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="#dimen/nav_header_vertical_spacing"
android:text="I am the footer" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="I'm always at the bottom of the sidemenu" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Muhaiminurabir#gmail.com" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Follow Us"
android:textColor="#color/app_white"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="5">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
Finally you can see this