Java 类android.support.design.widget.CoordinatorLayout.LayoutParams 实例源码

项目:boohee_v5.6    文件:HeaderScrollingViewBehavior.java   
protected void layoutChild(CoordinatorLayout parent, View child, int layoutDirection) {
    View header = findFirstDependency(parent.getDependencies(child));
    if (header != null) {
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        Rect available = this.mTempRect1;
        available.set(parent.getPaddingLeft() + lp.leftMargin, header.getBottom() + lp.topMargin, (parent.getWidth() - parent.getPaddingRight()) - lp.rightMargin, ((parent.getHeight() + header.getBottom()) - parent.getPaddingBottom()) - lp.bottomMargin);
        Rect out = this.mTempRect2;
        GravityCompat.apply(resolveGravity(lp.gravity), child.getMeasuredWidth(), child.getMeasuredHeight(), available, out, layoutDirection);
        int overlap = getOverlapPixelsForOffset(header);
        child.layout(out.left, out.top - overlap, out.right, out.bottom - overlap);
        this.mVerticalLayoutGap = out.top - header.getBottom();
        return;
    }
    super.layoutChild(parent, child, layoutDirection);
    this.mVerticalLayoutGap = 0;
}
项目:boohee_v5.6    文件:FloatingActionButton.java   
private boolean updateFabVisibility(CoordinatorLayout parent, AppBarLayout appBarLayout, FloatingActionButton child) {
    if (((LayoutParams) child.getLayoutParams()).getAnchorId() != appBarLayout.getId() || child.getUserSetVisibility() != 0) {
        return false;
    }
    if (this.mTmpRect == null) {
        this.mTmpRect = new Rect();
    }
    Rect rect = this.mTmpRect;
    ViewGroupUtils.getDescendantRect(parent, appBarLayout, rect);
    if (rect.bottom <= appBarLayout.getMinimumHeightForVisibleOverlappingContent()) {
        child.hide(null, false);
    } else {
        child.show(null, false);
    }
    return true;
}
项目:boohee_v5.6    文件:FloatingActionButton.java   
private void offsetIfNeeded(CoordinatorLayout parent, FloatingActionButton fab) {
    Rect padding = fab.mShadowPadding;
    if (padding != null && padding.centerX() > 0 && padding.centerY() > 0) {
        LayoutParams lp = (LayoutParams) fab.getLayoutParams();
        int offsetTB = 0;
        int offsetLR = 0;
        if (fab.getRight() >= parent.getWidth() - lp.rightMargin) {
            offsetLR = padding.right;
        } else if (fab.getLeft() <= lp.leftMargin) {
            offsetLR = -padding.left;
        }
        if (fab.getBottom() >= parent.getBottom() - lp.bottomMargin) {
            offsetTB = padding.bottom;
        } else if (fab.getTop() <= lp.topMargin) {
            offsetTB = -padding.top;
        }
        fab.offsetTopAndBottom(offsetTB);
        fab.offsetLeftAndRight(offsetLR);
    }
}
项目:RxBinding    文件:SwipeDismissBehaviorObservable.java   
@Override protected void subscribeActual(Observer<? super View> observer) {
  if (!checkMainThread(observer)) {
    return;
  }
  if (!(view.getLayoutParams() instanceof LayoutParams)) {
    throw new IllegalArgumentException("The view is not in a Coordinator Layout.");
  }
  LayoutParams params = (LayoutParams) view.getLayoutParams();
  final SwipeDismissBehavior behavior = (SwipeDismissBehavior) params.getBehavior();
  if (behavior == null) {
    throw new IllegalStateException("There's no behavior set on this view.");
  }
  Listener listener = new Listener(behavior, observer);
  observer.onSubscribe(listener);
  behavior.setListener(listener);
}
项目:CoordinatorExamples    文件:SwipeBehaviorExampleActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_swipe_behavior);


    final SwipeDismissBehavior swipe = new SwipeDismissBehavior();
    swipe.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_ANY);
    swipe.setListener(new SwipeDismissBehavior.OnDismissListener() {
        @Override public void onDismiss(View view) {
            Toast.makeText(SwipeBehaviorExampleActivity.this,
                "Card swiped !!", Toast.LENGTH_SHORT).show();
        }

        @Override public void onDragStateChanged(int state) {}
    });

    CardView cardView = (CardView) findViewById(R.id.swype_card);
    LayoutParams coordinatorParams = (LayoutParams) cardView.getLayoutParams();
    coordinatorParams.setBehavior(swipe);
}
项目:joy-library    文件:FloatingActionButtonBehavior.java   
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton floatingActionButton, View dependency) {

    if (dependency instanceof AppBarLayout) {

        AppBarLayout appBarLayout = (AppBarLayout) dependency;
        LayoutParams lp = (LayoutParams) floatingActionButton.getLayoutParams();
        int distanceToScroll = floatingActionButton.getHeight() + lp.bottomMargin;
        float ratio = ViewCompat.getY(appBarLayout) / (float) appBarLayout.getTotalScrollRange();
        ViewCompat.setTranslationY(floatingActionButton, -distanceToScroll * ratio);
        return true;
    }
    return super.onDependentViewChanged(parent, floatingActionButton, dependency);
}
项目:core-ui    文件:FloatingActionButtonBehavior.java   
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton floatingActionButton, View dependency) {
    if (dependency instanceof AppBarLayout) {
        AppBarLayout appBarLayout = (AppBarLayout) dependency;
        LayoutParams lp = (LayoutParams) floatingActionButton.getLayoutParams();
        int distanceToScroll = floatingActionButton.getHeight() + lp.bottomMargin;
        float ratio = ViewCompat.getY(appBarLayout) / (float) appBarLayout.getTotalScrollRange();
        ViewCompat.setTranslationY(floatingActionButton, -distanceToScroll * ratio);
        return true;
    }
    return super.onDependentViewChanged(parent, floatingActionButton, dependency);
}
项目:DrawerBehavior    文件:ContentScrimDrawer.java   
Base(CoordinatorLayout parent, View child) {
  super(parent.getContext());
  // Draw at the same level of the child.
  parent.addView(this, parent.indexOfChild(child),
      new LayoutParams(MATCH_PARENT, MATCH_PARENT));
}