简体   繁体   English

具有自定义布局的透明导航抽屉 - Android

[英]Transparent Navigation Drawer with Custom Layout - Android

Trying to make Totally transparent Navigation Drawer with Custom Design (trying to include only Custom layout ).尝试使用自定义设计制作完全透明的Navigation Drawer (尝试仅包含自定义layout )。

  • Transparent background and Zero elevation in Navigation Drawer . Navigation Drawer中的透明背景和零elevation
  • I do not want default header or menu items , I want to add custom design in other xml Layout then include inside我不想要默认header或菜单items ,我想在其他 xml Layout中添加自定义设计,然后包含在里面

How can I achieve this?我怎样才能做到这一点?

Video Example:视频示例: 在此处输入图像描述

If you want, make your Navigation Drawer totally Transparent then use this.如果你愿意,让你的Navigation Drawer完全Transparent ,然后使用它。 You can make your custom design in xml then include inside NavigationView .您可以在xml中进行自定义设计,然后将其includeNavigationView中。

<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerlayout" <!-- we will use this layout id in java for hide elevation -->
android:orientation="vertical"
android:focusableInTouchMode="true"
>

<com.google.android.material.navigation.NavigationView
    android:background="@android:color/transparent" <!-- for transparent -->
    android:layout_width="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    android:layout_height="match_parent">

    <include layout="@layout/custom_nav_drawer" />

</com.google.android.material.navigation.NavigationView>

</androidx.drawerlayout.widget.DrawerLayout>

in our Activity java class for hide drawer Shadow/elevation在我们的Activity java类中用于隐藏drawer阴影/高程

DrawerLayout drawerLayout=findViewById(R.id.drawerlayout);
drawerLayout.setDrawerElevation(0f);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM