package gnph.android;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

public class LinearBox extends LinearLayout {

    public LinearBox(Context context) {
        super(context);
    }
    public LinearBox(ViewGroup box) {
        super(box.getContext());
        box.addView(this);
    }

    public LinearBox horizontal() {
        setOrientation(HORIZONTAL);
        return this;
    }
    public LinearBox vertical() {
        setOrientation(VERTICAL);
        return this;
    }

    public LinearBox addSpacing(int spacing) {
        if(getOrientation()==HORIZONTAL) addView(new View(getContext()), new LayoutParams(spacing, 0));
        else addView(new View(getContext()), new LayoutParams(0, spacing));
        return this;
    }
    public LinearBox addStretch() {
        addView(new View(getContext()), new LayoutParams(0, 0,1));
        return this;
    }
}
