Browse Source

Animate Toolbar toggle

Guy Carmeli 8 years ago
parent
commit
c1d121608c

+ 4
- 2
android/app/src/main/java/com/reactnativenavigation/views/RnnToolBar.java View File

118
         ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
118
         ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
119
         if (actionBar != null) {
119
         if (actionBar != null) {
120
             actionBar.setShowHideAnimationEnabled(animated);
120
             actionBar.setShowHideAnimationEnabled(animated);
121
-            actionBar.show();
121
+            // We hide the ToolBar's parent (AppBarLayout) since this animates the shadow added by AppBar as well
122
+            ((View) getParent()).setVisibility(VISIBLE);
122
         }
123
         }
123
     }
124
     }
124
 
125
 
126
         ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
127
         ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
127
         if (actionBar != null) {
128
         if (actionBar != null) {
128
             actionBar.setShowHideAnimationEnabled(animated);
129
             actionBar.setShowHideAnimationEnabled(animated);
129
-            actionBar.hide();
130
+            // We hide the ToolBar's parent (AppBarLayout) since this animates the shadow added by AppBar as well
131
+            ((View) getParent()).setVisibility(GONE);
130
         }
132
         }
131
     }
133
     }
132
 
134
 

+ 2
- 1
android/app/src/main/res/layout/bottom_tab_activity.xml View File

5
     android:orientation="vertical"
5
     android:orientation="vertical"
6
     android:layout_width="match_parent"
6
     android:layout_width="match_parent"
7
     android:layout_height="match_parent"
7
     android:layout_height="match_parent"
8
-    tools:context=".activities.TabActivity">
8
+    tools:context=".activities.TabActivity"
9
+    android:animateLayoutChanges="true">
9
 
10
 
10
     <android.support.design.widget.AppBarLayout
11
     <android.support.design.widget.AppBarLayout
11
         android:id="@+id/appbar"
12
         android:id="@+id/appbar"