0

My goal is to create own app bar with some extra textviews. When I add new activity to my application, AppBar shadow is visible immediately. Problem is when I hide default appbar using AppTheme.NoActionBar in manifest and create my own application bar using AppBarLayout. After that, activity loads app bar without shadow (shadow is visible in next 1 second). Can anybody tell me, how to load shadow in no time?

enter image description here

Manifest

 <activity android:name=".activity.Example"
        android:theme="@style/AppTheme.NoActionBar"/>

styles.xml

<style name="AppTheme.NoActionBar">
   <item name="windowActionBar">false</item>
   <item name="windowNoTitle">true</item>
</style>

v21\styles.xml

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

activity_example.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <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="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

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

</RelativeLayout>
  • I am not sure what is making that shadow, because you didn't put `android:elevation="8dp"` on your toolbar. Try doing that. – Vladimir Jovanović Sep 28 '16 at 12:17
  • I added android:elevation="40dp" to AppBarLayout to see what happen. When activity starts, 40dp elevation is shown, but after 1 second, shadow (elevation) is somehow changed to 4dp.... Dont know, what is doing that. – Jan Petrskovský Sep 28 '16 at 12:48
  • I can solve this by setting android:elevation to 4dp, so change will not be visible, but something (maybe from support library) is changing that shadow. – Jan Petrskovský Sep 28 '16 at 12:50
  • Look at this question http://stackoverflow.com/a/32393698/1120982 Helped for me – Tooto Oct 11 '16 at 10:04

0 Answers0