的LinearLayout重叠的支持CoordinatorLayout [英] LinearLayout overlapping Support CoordinatorLayout

查看:1208
本文介绍了的LinearLayout重叠的支持CoordinatorLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次使用CoordinatorLayout,我真的不明白它是如何工作的。

It's the first time I use CoordinatorLayout, and I don't really understand how it works.

我的LinearLayout是重叠的工具栏我,就好像我是一个的FrameLayout,或RelativeLayout的,我不知道该怎么告诉它下面去(如Android:与RelativeLayout的layout_below)

My LinearLayout is overlapping my Toolbar, as if I were in a FrameLayout, or RelativeLayout, and I don't know how to tell it to go below ( Like android:layout_below with RelativeLayout )

下面是我的code:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="192dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/backdrop"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:src="@drawable/logo2"
                app:layout_collapseMode="pin" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/appbar"
        android:orientation="vertical"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin">

            .... Very Large Form ...
    </LinearLayout>
</android.support.design.widget.CoordinatorLayout>

另外一个疑问:几乎所有我看到的例子是与CoordinateLayout管理RecyclerView。
我的布局是不是RecyclerView,只是一个很长的表格。是否有意义做这种方式?

Another doubt: Almost all the examples I saw were with CoordinateLayout managing RecyclerView. My Layout is not a RecyclerView, just a very long form. Does it make sense doing it this way?

推荐答案

尝试嵌套一个NestedScrollView内您的内容。不要忘了包括layout_behavior XML标记。

Try nesting your content inside of a NestedScrollView. Don't forget to include the layout_behavior XML tag.

 <android.support.v4.widget.NestedScrollView
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         app:layout_behavior="@string/appbar_scrolling_view_behavior">

     <!-- Your scrolling content -->

 </android.support.v4.widget.NestedScrollView>

其他资源:
http://developer.android.com/reference/android/support/design/widget/AppBarLayout.html

这篇关于的LinearLayout重叠的支持CoordinatorLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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