/** * 这个方法是用来子view用来布局自身使用,如果依赖其他view,那么系统会首先调用 * public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) * 这个方法,可以在这个回调中记录dependency的一些位置信息,在onLayoutChild中利用保存下来的信息进行计算,然后得到自身的具体位置。 */ @Override public boolean onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection) { boolean bool = super.onLayoutChild(parent, child, layoutDirection); if (isPrepared) updateView(child, parent.getDependencies(child).get(0)); return bool; }
@Override public boolean onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection) { Log.i(TAG,"onLayoutChild....."); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); if(params!=null && params.height == CoordinatorLayout.LayoutParams.MATCH_PARENT){ child.layout(0,0,parent.getWidth(),parent.getHeight()); child.setTranslationY(getHeaderHeight()); return true; } return super.onLayoutChild(parent, child, layoutDirection); }
@Override public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); layoutParams.gravity = Gravity.BOTTOM; return super.onLayoutChild(parent, child, layoutDirection); }
@Override public boolean onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection) { final List<View> dependencies = parent.getDependencies(child); final View header = findFirstDependency(dependencies); if (header != null) { final CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); final Rect available = mTempRect1; //列表可用的 layoutParams . bottom 是为了 列表的高度为parent的可用高度 available.set(parent.getPaddingLeft() + lp.leftMargin, header.getBottom() + lp.topMargin, parent.getWidth() - parent.getPaddingRight() - lp.rightMargin, parent.getHeight() + header.getBottom() - parent.getPaddingBottom() - lp.bottomMargin); final Rect out = mTempRect2; //设置gravity GravityCompat.apply(resolveGravity(lp.gravity), child.getMeasuredWidth(), child.getMeasuredHeight(), available, out, layoutDirection); child.layout(out.left, out.top, out.right, out.bottom); } else { // If we don't have a dependency, let super handle it super.onLayoutChild(parent, child, layoutDirection); } return true; }
@Override public boolean onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection) { return super.onLayoutChild(parent, child, layoutDirection); } }
@Override public boolean onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection) { CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); if (params != null && params.height == CoordinatorLayout.LayoutParams.MATCH_PARENT) { child.layout(0, mTargetCurrentOffset, parent.getWidth(), parent.getHeight() + mTargetCurrentOffset); return true; } return super.onLayoutChild(parent, child, layoutDirection); }
@Override public boolean onLayoutChild(CoordinatorLayout parent, ShopInfoContainer child, int layoutDirection) { boolean handled = super.onLayoutChild(parent, child, layoutDirection); if (mContainer == null) { mContainer = new WeakReference<>(child); name_container = child.findViewById(R.id.name_container); iv_shop = child.findViewById(R.id.iv_shop); iv_shop_bg = child.findViewById(R.id.iv_shop_bg); } return handled; }
/** * 这个方法是用来子view用来布局自身使用,如果依赖其他view,那么系统会首先调用 * public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) * 这个方法,可以在这个回调中记录dependency的一些位置信息,在onLayoutChild中利用保存下来的信息进行计算,然后得到自身的具体位置。 */ @Override public boolean onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection) { boolean bool = super.onLayoutChild(parent, child, layoutDirection); if (isPrepared) updateView(child, parent.getDependencies(child).get(0)); return bool; }
/** * 这个方法是用来子view用来布局自身使用,如果依赖其他view,那么系统会首先调用 * public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) * 这个方法,可以在这个回调中记录dependency的一些位置信息,在onLayoutChild中利用保存下来的信息进行计算,然后得到自身的具体位置。 */ @Override public boolean onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection) { boolean bool = super.onLayoutChild(parent, child, layoutDirection); if (isPrepared) updateView(child, parent.getDependencies(child).get(0)); return bool; }
@Override public boolean onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection) { CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); if(params!=null && params.height == CoordinatorLayout.LayoutParams.MATCH_PARENT){ child.layout(0,0,parent.getWidth(),parent.getHeight()- getHeaderCollspateHeight()); return true; } return super.onLayoutChild(parent, child, layoutDirection); }