Невозможно щелкнуть пункты меню на панели навигации - PullRequest
1 голос
/ 23 марта 2020

Я недавно добавил NavigationDrawer в основной раздел моей деятельности. Мне нравится макет и все, однако, я не могу щелкнуть элементы в панели навигации, которые затем создадут фрагмент.

Я пытался понять это в течение пары недель без какого-либо успеха. Может ли кто-нибудь помочь мне с этим? Спасибо.

Мне кажется, это как-то связано с моим макетом моего XML файла.

Вот моя основная деятельность xml.

 <?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawerLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:orientation="vertical"
        android:background="#FFFFFF">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:background="#34526F"
            android:src="@mipmap/ic_launcher"/>

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

        <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"
            app:itemTextAppearance="@style/AppTheme"
            app:elevation="4dp"
            app:menu="@menu/drawer_menu" />

    </LinearLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbarMain"
            android:layout_width="match_parent"
            android:layout_height="?actionBarSize"
            android:alignmentMode="alignBounds"
            android:background="#FFFFFF"
            android:columnCount="4"
            android:columnOrderPreserved="false"
            android:elevation="4dp"
            android:useDefaultMargins="true">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center_horizontal"
                android:layout_marginRight="64dp"
                android:fontFamily="@font/open_sans_light"
                android:gravity="center"
                android:outlineAmbientShadowColor="@color/colorPrimaryDark"
                android:text="V E N D O R S"
                android:textColor="#777777"
                android:typeface="monospace" />


        </androidx.appcompat.widget.Toolbar>

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/toolbarMain">

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <LinearLayout
                    android:id="@+id/topMostLinear"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                    <ImageButton
                        android:id="@+id/mua_button"
                        android:layout_width="200dp"
                        android:layout_height="170dp"
                        android:layout_marginLeft="8dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginRight="4dp"
                        android:layout_marginBottom="4dp"
                        android:layout_weight="1"
                        android:background="@drawable/mua_image"
                        android:onClick="mua_list"></ImageButton>

                    <ImageButton
                        android:id="@+id/photography_button"
                        android:layout_width="200dp"
                        android:layout_height="170dp"
                        android:layout_marginLeft="4dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginRight="8dp"
                        android:layout_marginBottom="4dp"
                        android:layout_weight="1"
                        android:background="@drawable/photography_image"
                        android:onClick="photography_list">>
                    </ImageButton>

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/secondMostLinear"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/topMostLinear">

                    <ImageButton
                        android:id="@+id/videography_button"
                        android:layout_width="200dp"
                        android:layout_height="170dp"
                        android:layout_marginLeft="8dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginRight="4dp"
                        android:layout_marginBottom="4dp"
                        android:layout_weight="1"
                        android:background="@drawable/videography_image"
                        android:onClick="videography_list"></ImageButton>

                    <ImageButton
                        android:id="@+id/catering_button"
                        android:layout_width="200dp"
                        android:layout_height="170dp"
                        android:layout_marginLeft="4dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginRight="8dp"
                        android:layout_marginBottom="4dp"
                        android:layout_weight="1"
                        android:background="@drawable/catering_image"
                        android:onClick="catering_list"></ImageButton>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/thirdMostLinear"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/secondMostLinear">

                    <ImageButton
                        android:id="@+id/dias_button"
                        android:layout_width="200dp"
                        android:layout_height="170dp"
                        android:layout_marginLeft="8dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginRight="4dp"
                        android:layout_marginBottom="4dp"
                        android:layout_weight="1"
                        android:background="@drawable/dias_image"
                        android:onClick="dias_list"></ImageButton>

                    <ImageButton
                        android:id="@+id/entertainment_button"
                        android:layout_width="200dp"
                        android:layout_height="170dp"
                        android:layout_marginLeft="4dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginRight="8dp"
                        android:layout_marginBottom="4dp"
                        android:layout_weight="1"
                        android:background="@drawable/entertainment_image"
                        android:onClick="entertainment_list"></ImageButton>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/fourthMostLinear"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/thirdMostLinear">

                    <ImageButton
                        android:id="@+id/venue_button"
                        android:layout_width="200dp"
                        android:layout_height="170dp"
                        android:layout_marginLeft="8dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginRight="4dp"
                        android:layout_marginBottom="4dp"
                        android:layout_weight="1"
                        android:background="@drawable/venue_image"
                        android:onClick="venue_list"></ImageButton>

                    <ImageButton

                        android:id="@+id/gift_button"
                        android:layout_width="200dp"
                        android:layout_height="170dp"
                        android:layout_marginLeft="4dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginRight="8dp"
                        android:layout_marginBottom="4dp"
                        android:layout_weight="1"
                        android:background="@drawable/gift_image"
                        android:onClick="gift_list"></ImageButton>
                </LinearLayout>
            </RelativeLayout>

        </ScrollView>
    </RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>

1 Ответ

0 голосов
/ 23 марта 2020

Вы можете попробовать это

    nav_view.bringToFront();
...