Enabled the floating search bar feature

Added the CoordinatorLayout as the top level layout
Added the AppBarLayout to enclose the search bar
Added the app:layout_behavior="@string/appbar_scrolling_view_behavior" to NestedScrollView

Bug: 118886724
Test: manual test
Change-Id: I4a8ef14637dc1dc7cf9618eca00e4b7d7a77c725
This commit is contained in:
Sunny Shao
2018-11-13 16:47:36 +08:00
parent 4864624c3d
commit 2c93ec8ae3
2 changed files with 28 additions and 15 deletions

View File

@@ -21,6 +21,7 @@
android:id="@+id/search_bar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
android:background="?android:attr/colorPrimary">
<androidx.cardview.widget.CardView
android:id="@+id/search_bar"

View File

@@ -15,19 +15,30 @@
limitations under the License.
-->
<androidx.core.widget.NestedScrollView
<androidx.coordinatorlayout.widget.CoordinatorLayout
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="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/search_bar"/>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants">
<include layout="@layout/search_bar"/>
<FrameLayout
android:id="@+id/contextual_cards_content"
android:layout_width="match_parent"
@@ -40,3 +51,4 @@
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>