简体   繁体   English

如何从Android Studio中的DrawerLayout中删除高程(阴影)?

[英]How to remove elevation (drop shadow) from a DrawerLayout in Android Studio?

How can I remove the elevation (drop shadow) from a DrawerLayout in Android Studio? 如何从Android Studio中的DrawerLayout中删除高程(阴影)? I've looked everywhere, and tried adding app:elevation="0dp" and android:elevation="0dp" to my DrawerLayout xml, but it doesn't work. 我到处寻找,并尝试将app:elevation="0dp"android:elevation="0dp"到我的DrawerLayout xml中,但它不起作用。

I even tried adding setElevation(0f) to my MainActivity , but that didn't work either. 我甚至尝试将setElevation(0f)添加到我的MainActivity ,但这也不起作用。

What am I doing wrong? 我究竟做错了什么? Thanks. 谢谢。

(PS The project's base API is 16... I tried changing it to 21, but that didn't make any difference.) (PS该项目的基础API为16 ...我尝试将其更改为21,但这没有任何区别。)

Here's my onCreate: 这是我的onCreate:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "MUHAHA BURP BARF BARF WHAHAHA", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });

        DrawerLayout drawer = (DrawerLayout) findViewById(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);

        populateListView();
    }

Solved it. 解决了它。 Turns out I was trying to remove the elevation from drawer_layout when I should've been removing it from drawer . 事实证明,当我应该从drawer取出时,我试图从drawer_layout删除高程。 Putting drawer.setDrawerElevation(0f); 放置drawer.setDrawerElevation(0f); in my MainActivity fixed the problem. 在我的MainActivity解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM