Remove android.widget.Toolbar shadow

后端 未结 10 1307
庸人自扰
庸人自扰 2021-02-02 05:34

Using API21+ Toolbar:

// Toolbar
Toolbar toolbar = new Toolbar(this);
toolbar.showOverflowMenu();

Would like to remove its shadow

10条回答
  •  逝去的感伤
    2021-02-02 06:01

    Use attribute app:elevation="0dp" to your Toolbar or AppBarLayout to remove the shadow.

    #. If you are using Toolbar only, then add attribute app:elevation="0dp" to Toolbar.

        
    

    #. If you are using AppBarLayout as a container of Toolbar, then add attribute app:elevation="0dp" to AppBarLayout.

        
    
            
    
        
    

    OUTPUT:

    UPDATE:

    If you want to remove it programmatically then you can use below code:

    getSupportActionBar().setElevation(0);
    

    Hope this will help~

提交回复
热议问题