[英]Transparent Navigation Drawer with Custom Layout - Android
嘗試使用自定義設計制作完全透明的Navigation Drawer
(嘗試僅包含自定義layout
)。
Navigation Drawer
中的透明背景和零elevation
。header
或菜單items
,我想在其他 xml Layout
中添加自定義設計,然后包含在里面我怎樣才能做到這一點?
如果你願意,讓你的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>
在我們的Activity
java
類中用於隱藏drawer
陰影/高程
DrawerLayout drawerLayout=findViewById(R.id.drawerlayout);
drawerLayout.setDrawerElevation(0f);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.