android - Toolbar transparent with navigation drawer -
i trying make toolbar transparent navigation drawer. working fine til api<21, above api 21 toolbar not transparent. have added theme v-21 style folder well. adding theme image.
<style name="apptheme.noactionbar"> <item name="windowactionbar">false</item> <item name="windownotitle">true</item> <item name="colorprimary">@android:color/transparent</item> <item name="colorprimarydark">@color/colorprimarydark</item> <item name="drawerarrowstyle">@style/drawerarrowstyle</item> </style> <style name="drawerarrowstyle" parent="widget.appcompat.drawerarrowtoggle"> <item name="color">@color/colorprimary</item> </style>
moreover, have created background selector toolbar in colors transparent
xml
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:context="com.mayank.tracar.activties.mainactivity"> <android.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/apptheme.appbaroverlay"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="@drawable/toolbar_background" /> </android.support.design.widget.appbarlayout> <include layout="@layout/content_main" /> </android.support.design.widget.coordinatorlayout>
styles
<style name="apptheme.noactionbar"> <item name="windowactionbar">false</item> <item name="windownotitle">true</item> <item name="android:statusbarcolor">@android:color/transparent</item> <item name="android:windowdrawssystembarbackgrounds">true</item> <item name="colorprimary">@android:color/transparent</item> <item name="colorprimarydark">@color/colorprimarydark</item> <item name="drawerarrowstyle">@style/drawerarrowstyle</item> </style> <style name="apptheme.noactionbar"> <item name="windowactionbar">false</item> <item name="windownotitle">true</item> <item name="colorprimary">@android:color/transparent</item> <item name="colorprimarydark">@color/colorprimarydark</item> <item name="drawerarrowstyle">@style/drawerarrowstyle</item> </style>
finally solved changing these things in code. hope else well.
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:context="com.mayank.tracar.activties.mainactivity"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="@drawable/toolbar_background" /> <include layout="@layout/content_main" /> </android.support.design.widget.coordinatorlayout>
if remove appbarlayout toolbar goes behind include layout, solve call toolbar.bringtofront()
on oncreate
, works fine now.
Comments
Post a Comment