Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
// Request customization: add request headers Request.BuilderrequestBuilder= original.newBuilder() .header("headerkey", "header-value"); // <-- this is the important line
@Override protectedvoidonLayout(boolean changed, int l, int t, int r, int b) { intpaddingLeft= getPaddingLeft(); intpaddingRight= getPaddingRight(); intpaddingTop= getPaddingTop(); intpaddingBottom= getPaddingBottom();
intchildCount= getChildCount(); //摆放每一个孩子的高度 for (inti=0; i < childCount; i++) { Viewchild= getChildAt(i); if (child.getVisibility() != GONE) { int childNeededWidth, childNeedHeight; int left, top, right, bottom;
int widthUsed = paddingLeft + paddingRight; int heightUsed = paddingTop + paddingBottom; ---------- if (widthUsed + childUsedWidth < widthSpecSize) { widthUsed += childUsedWidth; if (childUsedHeight > childMaxHeightOfThisLine) { childMaxHeightOfThisLine = childUsedHeight; } }
为了支持子控件的margin属性,我们同样也做了处理
1 2 3 4 5 6 7 8
Rect marginRect = getMarginRect(child); int leftMargin=marginRect.left; int rightMargin=marginRect.right; int topMargin=marginRect.top; int bottomMargin=marginRect.bottom; childUsedWidth += leftMargin + rightMargin; childUsedHeight += topMargin + bottomMargin;
/** * 放置每个子控件的位置 * * @param changed * @param l * @param t * @param r * @param b */ @Override protectedvoidonLayout(boolean changed, int l, int t, int r, int b) { l += getPaddingLeft(); t += getPaddingTop(); for (inti=0; i < mLines.size(); i++) { Lineline= mLines.get(i); //设置每一行的位置,每一行的子控件由其自己去分配 line.onLayout(l, t); //距离最顶端的距离,即每一行高度和垂直间距的累加 t += line.getHeight() + verticalSpacing; } }
// 当CoordinatorLayout的直接或者非直接子View开始嵌套滑动的时候,会调用这个方法 boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes)
// 当嵌套滑动的时候,target 尝试滑动或者正在滑动会调用这个方法 onNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)
public ScaleDownShowBehavior(Context context, AttributeSet attrs) { super(); }
@Override public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View directTargetChild, View target, int nestedScrollAxes) { return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL; }
@Override public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { if ((dyConsumed > 0 || dyUnconsumed > 0) && !isAnimatingOut && child.getVisibility() == View.VISIBLE) {//往下滑 AnimatorUtil.scaleHide(child, viewPropertyAnimatorListener); if (mOnStateChangedListener != null) { mOnStateChangedListener.onChanged(false); } } else if ((dyConsumed < 0 || dyUnconsumed < 0) && child.getVisibility() != View.VISIBLE) { AnimatorUtil.scaleShow(child, null); if (mOnStateChangedListener != null) { mOnStateChangedListener.onChanged(true); } } }
public void setOnStateChangedListener(OnStateChangedListener mOnStateChangedListener) { this.mOnStateChangedListener = mOnStateChangedListener; }
// 外部监听显示和隐藏。 public interface OnStateChangedListener { void onChanged(boolean isShow); }
public static <V extends View> ScaleDownShowBehavior from(V view) { ViewGroup.LayoutParams params = view.getLayoutParams(); if (!(params instanceof CoordinatorLayout.LayoutParams)) { throw new IllegalArgumentException("The view is not a child of CoordinatorLayout"); } CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) params).getBehavior(); if (!(behavior instanceof ScaleDownShowBehavior)) { throw new IllegalArgumentException("The view is not associated with ScaleDownShowBehavior"); } return (ScaleDownShowBehavior) behavior; }
private ViewPropertyAnimatorListener viewPropertyAnimatorListener = new ViewPropertyAnimatorListener() {
@Override public void onAnimationStart(View view) { isAnimatingOut = true; }
The view will act as normal with no collapsing behavior.(这个 View将会 呈现正常的结果,不会表现出折叠效果)
int COLLAPSE_MODE_PARALLAX
The view will scroll in a parallax fashion. See setParallaxMultiplier(float) to change the multiplier used.(在滑动的时候这个View 会呈现 出 视觉特差效果 )
int COLLAPSE_MODE_PIN
The view will pin in place until it reaches the bottom of the CollapsingToolbarLayout.(当这个View到达 CollapsingToolbarLayout的底部的时候,这个View 将会被放置,即代替整个CollapsingToolbarLayout)