Set elevation still display shadow below ActionBar in Android

走远了吗. 提交于 2019-12-11 14:03:29

问题


Inside values/styles.xml I have set <item name="elevation">0dp</item> to my AppTheme style. and inside values-21/styles.xml I have set <item name="android:elevation">0dp</item> and I Have also try this <item name="android:windowContentOverlay">@null</item>.I have also try to Clean the Project and Rebuild the Project. and also try to Invalidate Caches and Restart. But my Emulator still display shadow see the below screen.

Question :

How to remove that shadow below to ActionBar.

ScreenShot :


回答1:


I don't know why elevation is not work in style. but When I set it programatically It's just work fine.

 getSupportActionBar().setElevation(0);

Output :




回答2:


If this is a pure ActionBar, and not a Toolbar. This is how you do it :

<style name="MyAppTheme" parent="Theme.AppCompat.Light">
  <item name="actionBarStyle">@style/FlatActionBar</item>
</style>

<style name="FlatActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid">
  <item name="elevation">0dp</item>
</style>



回答3:


Put your toolbar in this.

<android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:elevation="0dp">

        ...

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


来源:https://stackoverflow.com/questions/37985505/set-elevation-still-display-shadow-below-actionbar-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!