【问题标题】:Transparent Navigation Drawer with Custom Layout - Android具有自定义布局的透明导航抽屉 - Android
【发布时间】:2022-12-24 01:29:23
【问题描述】:

尝试使用自定义设计使完全透明Navigation Drawer(尝试包括 仅自定义 layout)。

  • 透明背景和Navigation Drawer 中的零elevation
  • 我不想要默认header或菜单items,我想在其他xmlLayout中添加自定义设计然后包含在里面

我怎样才能做到这一点?

【问题讨论】:

    标签: android navigation-drawer


    【解决方案1】:

    视频示例:

    如果你愿意,让你的Navigation Drawer完全Transparent然后使用它。您可以在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>
    

    在我们的Activityjava隐藏类drawer阴影/海拔

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-22
      • 2013-10-22
      • 1970-01-01
      • 1970-01-01
      • 2017-01-01
      • 1970-01-01
      相关资源
      最近更新 更多