public void initMargins(Rect margins, View view) {
    LayoutParams layoutParams = view.getLayoutParams();

    if (layoutParams instanceof MarginLayoutParams) {
      MarginLayoutParams marginLayoutParams = (MarginLayoutParams) layoutParams;
      initMarginRect(margins, marginLayoutParams);
    } else {
        margins.set(0, 0, 0, 0);
    }
  }
Populates {@link Rect} with margins for any view.


@param margins rect to populate
@param view for which to get margins
library/src/main/java/com/timehop/stickyheadersrecyclerview/calculation/DimensionCalculator.java