当FloatingAcitonButton锚定到View时,如何扩展CoordinatorLayout.Behavior <floatingactionbutton>

时间:2016-08-26 20:07:48

标签: android android-layout android-coordinatorlayout floating-action-button

这是我的布局 - &gt;

1 - &gt; collapsingToolbarLayout中的一个布局和一个View用于管理此布局

这是我的布局

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

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/movie.app_bar_layout"
    >
    <android.support.design.widget.CollapsingToolbarLayout
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:id="@+id/movie.toolbar_layout"
        app:layout_scrollFlags="enterAlwaysCollapsed|scroll"
        >
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:src="@drawable/poster"
            app:layout_collapseMode="parallax"/>


        <View
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:background="@color/colorPrimary"
            android:id="@+id/movie.innerview"
            android:layout_gravity="bottom"/>

        <include
            layout="@layout/movie.profile"
            android:id="@+id/movie.inner_layout"/>

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

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

<include
    layout="@layout/content_scrolling"/>

<android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@android:drawable/ic_media_ff"
    app:layout_anchor="@id/movie.innerview"
   app:layout_behavior="com.express.entertain.profileapp.ImageBehaviour"
    app:layout_anchorGravity="top|right"
    android:id="@+id/movie.fab"/>

我很难做出行为 - &gt;

1 - &gt; layoutDependsOn背后的想法总是会返回true?

2→然后如何在onDependetViewChanged

中获取行为
 @Override
public boolean layoutDependsOn(CoordinatorLayout parent, FloatingActionButton child, View dependency) {


    return  false;
}

@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) {

    if (dependency instanceof CollapsingToolbarLayout){

    }

    return false;
}

0 个答案:

没有答案