Search in sources :

Example 1 with Insettable

use of com.android.launcher3.Insettable in project Neo-Launcher by NeoApplications.

the class InsettableLinearLayout method setLinearLayoutChildInsets.

public void setLinearLayoutChildInsets(View child, Rect newInsets, Rect oldInsets) {
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
    int childIndex = indexOfChild(child);
    int newTop = childIndex == 0 ? newInsets.top : 0;
    int oldTop = childIndex == 0 ? oldInsets.top : 0;
    int newBottom = childIndex == getChildCount() - 1 ? newInsets.bottom : 0;
    int oldBottom = childIndex == getChildCount() - 1 ? oldInsets.bottom : 0;
    if (child instanceof Insettable) {
        ((Insettable) child).setInsets(new Rect(newInsets.left, newTop, newInsets.right, newBottom));
    } else if (!lp.ignoreInsets) {
        lp.topMargin += (newTop - oldTop);
        lp.leftMargin += (newInsets.left - oldInsets.left);
        lp.rightMargin += (newInsets.right - oldInsets.right);
        lp.bottomMargin += (newBottom - oldBottom);
    }
    child.setLayoutParams(lp);
}
Also used : Rect(android.graphics.Rect) Insettable(com.android.launcher3.Insettable)

Aggregations

Rect (android.graphics.Rect)1 Insettable (com.android.launcher3.Insettable)1