我爲我的應用程序使用了2(左右)NavigationView,並且只想爲某些條件顯示正確的NavigationView。因此,在佈局文件中將其可見性設置爲「GONE」,並在需要時使其可見。但是,即使使它「完成」後,NavigationView仍然顯示出來。如何隱藏NavigationView? android:visibility =「gone」不起作用
任何想法如何隱藏它?
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.example.girishkhatri.tt0401.NavigationViewRight
android:id="@+id/nav_right_view"
android:layout_width="wrap_content"
android:layout_height="600dp"
android:layout_marginTop="80dp"
android:layout_gravity="right"
android:fitsSystemWindows="true"
android:visibility="gone" //not working as expected
app:itemBackground="@drawable/nav_item_selector"
app:headerLayout="@layout/nav_header_right"
app:menu="@menu/activity_right_drawer" />
加上'gravity'歸因於正確的...它會工作 –