Android 去掉toolbar阴影

第一步 给你的toolbar套上AppBarLayout

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"
    >

    <android.support.v7.widget.Toolbar
        android:id="@+id/id_tool_bar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        app:titleTextColor="#FFFFFF"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        />
</android.support.design.widget.AppBarLayout>

第二步 给AppBarLayout设置主题,在styles中定义并添加属性<item name="elevation">0dp</item>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
        <item name="elevation">0dp</item>
 </style>

最终效果:

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 179,001评论 25 709
  • 本章的主要的知识点:卡片式布局CardViewAppBarLayout下拉刷新可折叠式标题栏CollapsingT...
    努力生活的西鱼阅读 973评论 0 3
  • 两年了。 你离开的第二年,感觉自己没有什么起色, 唯一不同的可能是自己思想成熟了。 还是会时常想起你,碰到有趣的人...
    PANSUGAR阅读 309评论 0 0
  • 人生在世,草木一秋。 还有什么想不通的? 出来混总是要还的,最近一直被这句话所萦绕。 终于明白什么叫感同身受,只有...
    随风而逝711阅读 234评论 0 0
  • 周六组织英语角和读书会活动,有个人报名说,担心参加活动会进入传销组织,当时听的很惊讶很气愤,这不就等于说我们是坏人...
    知识e站阅读 592评论 0 1

友情链接更多精彩内容