Search in sources :

Example 16 with ComponentSelector.$

use of com.codename1.ui.ComponentSelector.$ in project CodenameOne by codenameone.

the class ComponentSelector method setPaddingPercent.

/**
 * Sets padding on all components in found set as a percentage of their respective parents' dimensions.
 * @param top Top padding as percentage of parent height.
 * @param right Right padding as percentage of parent width.
 * @param bottom Bottom padding as percentage of parent height.
 * @param left Left padding as percentage of parent width.
 * @return
 */
public ComponentSelector setPaddingPercent(double top, double right, double bottom, double left) {
    for (Component c : this) {
        Component parent = c.getParent();
        if (parent != null) {
            // TODO : Change to currentStyle api... more complex with percents.
            Style s = getStyle(c);
            s.setPaddingUnit(Style.UNIT_TYPE_PIXELS, Style.UNIT_TYPE_PIXELS, Style.UNIT_TYPE_PIXELS, Style.UNIT_TYPE_PIXELS);
            s.setPadding(percentHeight(top, parent), percentHeight(bottom, parent), percentWidth(left, parent), percentWidth(right, parent));
        }
    }
    return this;
}
Also used : Style(com.codename1.ui.plaf.Style)

Aggregations

Style (com.codename1.ui.plaf.Style)9 SpanLabel (com.codename1.components.SpanLabel)5 ComponentAnimation (com.codename1.ui.animations.ComponentAnimation)5 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)3 SpanButton (com.codename1.components.SpanButton)2