美文网首页
Android 去掉toolbar阴影

Android 去掉toolbar阴影

作者: 我是一座离岛 | 来源:发表于2017-01-15 22:36 被阅读825次

第一步 给你的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>

最终效果:

相关文章

网友评论

      本文标题:Android 去掉toolbar阴影

      本文链接:https://www.haomeiwen.com/subject/dxsubttx.html