@Override public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) { if (child != null) { childeView = new WeakReference<View>(child); } if (dependency != null && dependency instanceof RelativeLayout) { dependentView = new WeakReference<>(dependency); return true; } return super.layoutDependsOn(parent, child, dependency); }
@Override public boolean layoutDependsOn(CoordinatorLayout parent, RelativeLayout child, View dependency) { float maxL = DensityUtil.dip2px(mContext, 150) + DensityUtil.getZhuangtai(mContext); Log.d("AAAAAAA", dependency.getY() + "拢共" + DensityUtil.dip2px(mContext, 356) + "toolsbar" + maxL); Message message = new Message(); if (dependency.getY() > 0) { float a = ((dependency.getY() - maxL) / (DensityUtil.dip2px(mContext, 356) - maxL)); Log.d("aaaa", "" + a); message.what = (int) (a * 100f); if (MyActivity.mHandler != null) MyActivity.mHandler.sendMessage(message); } return super.layoutDependsOn(parent, child, dependency); }
@Override public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) { Log.i(TAG, "layoutDependsOn"); CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) dependency.getLayoutParams(); if (lp.getBehavior() instanceof TargetBehavior) { return true; } return super.layoutDependsOn(parent, child, dependency); }
/** * 表示是否给应用了Behavior 的View 指定一个依赖的布局,通常,当依赖的View 布局发生变化时 * 不管被被依赖View 的顺序怎样,被依赖的View也会重新布局 * @param parent * @param child 绑定behavior 的View * @param dependency 依赖的view * @return 如果child 是依赖的指定的View 返回true,否则返回false */ @Override public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) { return super.layoutDependsOn(parent, child, dependency); }
/** * 用来决定需要监听哪些控件或者容器的状态(1、知道监听谁;2、什么状态改变) * * @param parent 父容器 * @param child 子控件--需要监听dependency这个view的视图们--观察者 * @param dependency 你要监听的那个view */ @Override public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) { // 还可以根据ID或者Tag来判断 return dependency instanceof TextView || super.layoutDependsOn(parent, child, dependency); }
@Override public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) { return super.layoutDependsOn(parent, child, dependency) || dependency instanceof FloatingActionButton; }
@Override public boolean layoutDependsOn(CoordinatorLayout parent, ImageView child, View dependency) { return super.layoutDependsOn(parent, child, dependency); }