Android onDependentViewChanged仅在依赖项';它的能见度改变了

Android onDependentViewChanged仅在依赖项';它的能见度改变了,android,kotlin,android-coordinatorlayout,behavior,Android,Kotlin,Android Coordinatorlayout,Behavior,我尝试实现一个简单的场景:单击按钮以显示/隐藏视图(依赖项)。显示视图(依赖项)时,向下移动另一个视图。但是onDependentViewChanged只调用一次。。。请帮我解决这个问题 <View android:id="@+id/child" android:layout_width="wrap_content" android:layout_height="wrap_content" an

我尝试实现一个简单的场景:单击按钮以显示/隐藏视图(依赖项)。显示视图(依赖项)时,向下移动另一个视图。但是onDependentViewChanged只调用一次。。。请帮我解决这个问题

<View
            android:id="@+id/child"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end|top"
            app:layout_behavior=".behavior.MoveDownBehavior">

<CustomizedView
        android:id="@+id/dependency"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top|center_horizontal"
        android:visibility="gone" />

class MoveDownBehavior(上下文:上下文,属性:属性集):
CoordinatorLayout.Behavior(上下文、属性){
//代码的其余部分是相同的
覆盖有趣的layoutDependsOn(父级:CoordinatorLayout,子级:V,依赖项:View):布尔值{
返回依赖项是CustomizedView
}
覆盖已更改的独立视图(
家长:协调人布局,
孩子:V,
依赖项:视图
):布尔值{
Timber.e(“dependency.visibility=${dependency.visibility}”)
//TODO根据dependency.visibility向下或向上移动子视图
返回super.onDependentViewChanged(父、子、依赖项)
}
}
怎么了

class MoveDownBehavior<V : View>(context: Context, attrs: AttributeSet) :
    CoordinatorLayout.Behavior<V>(context, attrs) {

    // Rest of the code is the same
    override fun layoutDependsOn(parent: CoordinatorLayout, child: V, dependency: View): Boolean {

        return dependency is CustomizedView
    }

    override fun onDependentViewChanged(
        parent: CoordinatorLayout,
        child: V,
        dependency: View
    ): Boolean {
        Timber.e("dependency.visibility = ${dependency.visibility}")

        // TODO according dependency.visibility to move down or up the child view

        return super.onDependentViewChanged(parent, child, dependency)
    }
}