如何在没有嵌套的scrollview的情况下实现新的材质gmail工具栏? [英] How I implement new material gmail toolbar without nested scrollview?

查看:63
本文介绍了如何在没有嵌套的scrollview的情况下实现新的材质gmail工具栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现不带嵌套滚动视图的新gmail类工具栏,该视图具有滚动功能,但是向下滚动时背景应该可见.

I want to implement new gmail like toolbar without nested scroll view, which is scroll able, but when scroll down background should be visible.

它看起来像这样:

推荐答案

它不是嵌套的滚动视图,它的 recyclerView . 如果您想要这样的搜索栏,则可以使用 CardView 进行搜索和Edittext或使用材料searchba r库.您可以使用frameLayout或CoordinatorLayout将其锁定在该位置.

It's not a nested scrollview, Its recyclerView. If you want such a search bar, you can make it using CardView and Edittext or use Material searchbar library. You can place it locked at that position by using frameLayout or CoordinatorLayout.

这是我制作的示例屏幕!

Here is a sample Screen I made!.

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:background="#dadada"
        android:layout_height="match_parent">

        <android.support.v7.widget.CardView
            app:cardUseCompatPadding="true"
            android:layout_margin="8dp"
            app:cardCornerRadius="8dp"
            android:layout_width="match_parent"
            android:layout_height="64dp">

            <android.support.constraint.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <ImageView
                    android:id="@+id/imageView2"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_marginStart="8dp"
                    android:src="@drawable/ic_menu_black_24dp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <EditText
                    android:id="@+id/editText"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="8dp"
                    android:layout_marginBottom="8dp"
                    android:background="@android:color/transparent"
                    android:hint="Search..."
                    android:minWidth="100dp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintStart_toEndOf="@+id/imageView2"
                    app:layout_constraintTop_toTopOf="parent" />

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_marginTop="8dp"
                    android:layout_marginEnd="8dp"
                    android:layout_marginBottom="8dp"
                    android:src="@drawable/ic_search_black_24dp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

            </android.support.constraint.ConstraintLayout>

        </android.support.v7.widget.CardView>

        <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        </android.support.v7.widget.RecyclerView>

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

这是结果.

这篇关于如何在没有嵌套的scrollview的情况下实现新的材质gmail工具栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆