我想要的是一个NavigationDrawer,它似乎与下面设计中的主要内容没有联系:

android - 抽屉导航中删除阴影-LMLPHP

我莫名其妙地从抽屉里弄不到阴影。

我试过的是:

drawer.setScrimColor(Color.TRANSPARENT);
drawer.setDrawerShadow(R.drawable.transparent, GravityCompat.START);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    drawer.setElevation(0f);
}


setScrimColor用于删除整个调光效果,但阴影仍然存在:

android - 抽屉导航中删除阴影-LMLPHP

我的activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include layout="@layout/app_bar_main" android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <LinearLayout
        android:layout_width="175dp"
        android:layout_height="match_parent"
        android:background="@color/backgroundColor"
        android:orientation="vertical"
        android:layout_gravity="start"
        android:id="@+id/navigationViews" />

</android.support.v4.widget.DrawerLayout>

最佳答案

将以下代码添加到您的JAVA类中。

drawer.setScrimColor(Color.TRANSPARENT);
drawer.setDrawerElevation(0);

10-07 19:32
查看更多