Android layout_behavior对包含的布局不起作用

时间:2016-08-05 07:33:39

标签: android android-layout android-coordinatorlayout

如果我有这样的布局,并且在FloatingActionsMenu上定义了layout_behavior,一切正常(使用行为):

people.name

然而,如果我尝试这样定义它,将FloatingActionsMenu代码提取到自己的布局:

<android.support.design.widget.CoordinatorLayout>

    <android.support.v4.view.ViewPager/>

    <me.henrytao.smoothappbarlayout.SmoothAppBarLayout>

        <android.support.design.widget.CollapsingToolbarLayout>

            <android.support.v7.widget.Toolbar>

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

        <android.support.design.widget.TabLayout>

    </me.henrytao.smoothappbarlayout.SmoothAppBarLayout>

    <com.getbase.floatingactionbutton.FloatingActionsMenu
        android:id="@+id/fab_menu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:layout_marginEnd="16dp"
        android:layout_gravity="bottom|end"
        fab:fab_addButtonColorNormal="@color/colorAccent"
        fab:fab_addButtonColorPressed="@color/colorAccentDark"
        fab:fab_addButtonPlusIconColor="@color/white"
        fab:fab_labelStyle="@style/menu_labels_style"
        app:layout_behavior=".views.ActionMenuBehavior"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:fab="http://schemas.android.com/apk/res-auto">

    </com.getbase.floatingactionbutton.FloatingActionsMenu>

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

未调用此行为。如果我将<android.support.design.widget.CoordinatorLayout> <android.support.v4.view.ViewPager/> <me.henrytao.smoothappbarlayout.SmoothAppBarLayout> <android.support.design.widget.CollapsingToolbarLayout> <android.support.v7.widget.Toolbar> </android.support.design.widget.CollapsingToolbarLayout> <android.support.design.widget.TabLayout> </me.henrytao.smoothappbarlayout.SmoothAppBarLayout> <include layout="@layout/floating_action_menu" app:layout_behavior=".views.ActionMenuBehavior"> </include> </android.support.design.widget.CoordinatorLayout> 移动到提取出的FloatingActionsMenu布局中,也不会调用它。

是否可以在包含的布局上使用 app:layout_behavior

0 个答案:

没有答案