【问题标题】:Android remove shadow of transparent navigation view [duplicate]Android删除透明导航视图的阴影[重复]
【发布时间】:2017-08-14 10:17:33
【问题描述】:

我有一个透明的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:elevation = 0 尝试了解决方案,但这会删除导航图标

【问题讨论】:

    标签: android android-toolbar navigation-drawer android-navigationview


    【解决方案1】:

    尝试将:app:elevation="0" 放入您的AppBarLayout。 这应该可以。

    【讨论】:

    • 是的,这是可行的,但这会隐藏我的导航图标
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-28
    • 2016-07-02
    • 2018-09-18
    • 1970-01-01
    相关资源
    最近更新 更多