0

The Logout layout overlap on the menu items in navigation drawer below 5.5 inch screen devices

enter image description here

This looks perfect in 5.5 inch screen devices

enter image description here

<?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="@drawable/drawer_bg"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:itemTextColor="@color/grey_text"
        app:menu="@menu/activity_main_drawer">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="#50000000"
            android:clickable="true"
            android:orientation="vertical">

            <TextView
                android:id="@+id/nav_logout"
                android:layout_width="match_parent"
                android:layout_height="44dp"
                android:gravity="center"
                android:text="Logout"
                android:textColor="@color/colorAccent"
                android:textSize="16sp" />

        </LinearLayout>

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


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

This is my xml codes. My question is how to let the logout layout become a part of navigation drawer in screen below 5.5 inch so that the user can scroll through the menu to reach to bottom to get the logout button.

Thank you.

tahsinRupam
  • 6,325
  • 1
  • 18
  • 34
Tony Zai
  • 26
  • 1
  • 5

3 Answers3

0

If your are trying to add the logout to the items in navigation list as like others and view the logout as you scroll down, if I get it right try using ListView instead of using logout alone and add logout as one of the items. I don't see your JAVA code for how you are adding other items. Hope it solves your problem.Here is a sample code:

`

<android.support.design.widget.NavigationView
        android:id="@+id/navi"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:menu="@menu/main_menu"
        android:background="#CCCCCC">
        <ListView
             xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:tools="http://schemas.android.com/tools"
             android:id="@+id/expnavimenu"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:choiceMode="singleChoice"
             android:dividerHeight="2dp"
             android:groupIndicator="@color/white"
             android:listSelector="@color/greyc4"
             android:childIndicator="@color/greyc4"
             android:background="@color/white"
             android:layout_marginTop="5dp"
             android:layout_marginBottom="5dp"/>
 </android.support.design.widget.NavigationView>

`

0

This solution works for me:

<com.google.android.material.navigation.NavigationView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start">

        <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true"
            android:scrollbars="vertical">

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

                <com.google.android.material.navigation.NavigationView
                    android:id="@+id/nav_view"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="start"
                    android:overScrollMode="never"
                    app:elevation="0dp"
                    app:headerLayout="@layout/nav_header_main"
                    app:itemIconTint="?attr/colorArrowDown"
                    app:menu="@menu/navigation_drawer_menu" />

                <LinearLayout
                    android:id="@+id/spacer_to_bottom"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:orientation="vertical" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom"
                    android:background="@drawable/background_white"
                    android:orientation="vertical"
                    android:padding="16dp">

                    <ImageView
                        android:layout_width="match_parent"
                        android:layout_height="32dp"
                        android:src="@drawable/ic_telegram" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:gravity="center"
                        android:text="@string/titleChanelTelegram"
                        android:textSize="@dimen/textSizeTiny" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:gravity="center"
                        android:text="@string/telegramID"
                        android:textColor="@color/colorBlack"
                        android:textSize="@dimen/textSizeNormal" />

                    <TextView
                        android:id="@+id/txt_version"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:gravity="center"
                        android:textSize="10dp" />
                </LinearLayout>
            </LinearLayout>
        </androidx.core.widget.NestedScrollView>
    </com.google.android.material.navigation.NavigationView>

I hope it unties the knot

Javid Sattar
  • 749
  • 8
  • 14
-1

For Click or handling footer:

NavigationView navigationView = (NavigationView) findViewById(R.id.navi);
    ListView footerLV = (ListView) navigationView.findViewById(R.id.expnavimenu);
    footerLV.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(MainActivity.this, "Footer is clicked", Toast.LENGTH_SHORT).show();
        }
    });