【发布时间】:2022-12-24 01:29:23
【问题描述】:
尝试使用自定义设计使完全透明Navigation Drawer(尝试包括
仅自定义 layout)。
- 透明背景和
Navigation Drawer中的零elevation。 - 我不想要默认
header或菜单items,我想在其他xmlLayout中添加自定义设计然后包含在里面
我怎样才能做到这一点?
【问题讨论】:
尝试使用自定义设计使完全透明Navigation Drawer(尝试包括
仅自定义 layout)。
Navigation Drawer 中的零elevation。header或菜单items,我想在其他xmlLayout中添加自定义设计然后包含在里面
我怎样才能做到这一点?
【问题讨论】:
如果你愿意,让你的Navigation Drawer完全Transparent然后使用它。您可以在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>
在我们的Activityjava隐藏类drawer阴影/海拔
DrawerLayout drawerLayout=findViewById(R.id.drawerlayout);
drawerLayout.setDrawerElevation(0f);
【讨论】: