Android: Deleting Shadow of Default ActionBar [dup

2019-07-25 03:26发布

This question already has an answer here:

Is there a way to remove the shadow from the default ActionBar? I only find solutions for custom ActionBars with "noActionBar" as default layout.

enter image description here

1条回答
一纸荒年 Trace。
2楼-- · 2019-07-25 03:44
getWindow().requestFeature(Window.FEATURE_ACTION_BAR); 
getSupportActionBar().setElevation(0);

note : Go to the activity you want to remove the ActionBar's Elevation. Before setContent(....), request the ActionBar feature(That is if you have not declared it directly)

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)        
    {
        toolbar.setElevation(0.0f);
    }
查看更多
登录 后发表回答