Android 移除透明导航视图的阴影

4

我有一个透明的NavigationView

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
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="false">

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/transparent"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:popupTheme="@style/AppTheme.PopupOverlay">

        </android.support.v7.widget.Toolbar>

    </android.support.design.widget.AppBarLayout>

工具栏是透明的,因为这个。
android:background="@drawable/transparent"

我想保留导航图标,但隐藏工具栏的阴影。我尝试了一些在SO上找到的解决方案,但都没有起作用。我尝试使用app:elevation = 0,但这会使我的工具栏图标消失。这是如何在Activity中实现导航的方式。
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);

编辑:这不是重复的问题,正如您在我的问题中看到的那样,我已经尝试使用app:elevatation = 0的解决方案,但这会删除导航图标。

1个回答

0
尝试在您的AppBarLayout中添加:app:elevation="0"。这应该可以解决问题。

1
是的,这个可以工作,但是它会隐藏我的导航图标。 - Vodet

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接