[英]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
)。
elevation
in Navigation Drawer
. Navigation Drawer
中的透明背景和零elevation
。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?我怎样才能做到这一点?
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
中进行自定义设计,然后将其include
在NavigationView
中。
<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.