Example usage for android.content.res TypedArray getLayoutDimension

List of usage examples for android.content.res TypedArray getLayoutDimension

Introduction

In this page you can find the example usage for android.content.res TypedArray getLayoutDimension.

Prototype

public int getLayoutDimension(@StyleableRes int index, int defValue) 

Source Link

Document

Special version of #getDimensionPixelSize for retrieving android.view.ViewGroup 's layout_width and layout_height attributes.

Usage

From source file:com.actionbarsherlock.internal.widget.ScrollingTabContainerView.java

@Override
protected void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    // Action bar can change size on configuration changes.
    // Reread the desired height from the theme-specified style.
    TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar,
            R.attr.actionBarStyle, 0);//from  ww w.j  a  va 2  s  . c o  m
    setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0));
    a.recycle();
}

From source file:com.actionbarsherlock.internal.widget.ScrollingTabContainerView.java

public ScrollingTabContainerView(Context context) {
    super(context);
    setHorizontalScrollBarEnabled(false);

    TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.SherlockActionBar,
            R.attr.actionBarStyle, 0);//from   w  w w.j a  va  2 s .  c  om
    setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0));
    a.recycle();

    mInflater = LayoutInflater.from(context);

    mTabLayout = createTabLayout();
    addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
}

From source file:com.actionbarsherlock.internal.widget.ActionBarContextView.java

public ActionBarContextView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionMode, defStyle, 0);
    setBackgroundDrawable(a.getDrawable(R.styleable.SherlockActionMode_background));
    mTitleStyleRes = a.getResourceId(R.styleable.SherlockActionMode_titleTextStyle, 0);
    mSubtitleStyleRes = a.getResourceId(R.styleable.SherlockActionMode_subtitleTextStyle, 0);

    mContentHeight = a.getLayoutDimension(R.styleable.SherlockActionMode_height, 0);

    mSplitBackground = a.getDrawable(R.styleable.SherlockActionMode_backgroundSplit);

    a.recycle();/*ww  w.  j av  a 2 s.co m*/
}

From source file:com.actionbarsherlock.internal.widget.IcsSpinner.java

/**
 * Construct a new spinner with the given context's theme, the supplied attribute set,
 * and default style.//from  w  w w.j  a  va  2 s  .  co m
 *
 * @param context The Context the view is running in, through which it can
 *        access the current theme, resources, etc.
 * @param attrs The attributes of the XML tag that is inflating the view.
 * @param defStyle The default style to apply to this view. If 0, no style
 *        will be applied (beyond what is included in the theme). This may
 *        either be an attribute resource, whose value will be retrieved
 *        from the current theme, or an explicit style resource.
 */
public IcsSpinner(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockSpinner, defStyle, 0);

    DropdownPopup popup = new DropdownPopup(context, attrs, defStyle);

    mDropDownWidth = a.getLayoutDimension(R.styleable.SherlockSpinner_android_dropDownWidth,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    popup.setBackgroundDrawable(a.getDrawable(R.styleable.SherlockSpinner_android_popupBackground));
    final int verticalOffset = a
            .getDimensionPixelOffset(R.styleable.SherlockSpinner_android_dropDownVerticalOffset, 0);
    if (verticalOffset != 0) {
        popup.setVerticalOffset(verticalOffset);
    }

    final int horizontalOffset = a
            .getDimensionPixelOffset(R.styleable.SherlockSpinner_android_dropDownHorizontalOffset, 0);
    if (horizontalOffset != 0) {
        popup.setHorizontalOffset(horizontalOffset);
    }

    mPopup = popup;

    mGravity = a.getInt(R.styleable.SherlockSpinner_android_gravity, Gravity.CENTER);

    mPopup.setPromptText(a.getString(R.styleable.SherlockSpinner_android_prompt));

    mDisableChildrenWhenDisabled = true;

    a.recycle();

    // Base constructor can call setAdapter before we initialize mPopup.
    // Finish setting things up if this happened.
    if (mTempAdapter != null) {
        mPopup.setAdapter(mTempAdapter);
        mTempAdapter = null;
    }
}

From source file:com.roselism.bottomsheet.BottomSheet.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    init(getContext());/*from   ww  w. ja v  a 2s . co m*/

    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    params.gravity = Gravity.BOTTOM;

    TypedArray a = getContext().obtainStyledAttributes(new int[] { android.R.attr.layout_width });
    try {
        params.width = a.getLayoutDimension(0, ViewGroup.LayoutParams.MATCH_PARENT);
    } finally {
        a.recycle();
    }
    super.setOnDismissListener(new OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            if (dismissListener != null) {
                dismissListener.onDismiss(dialog);
            }
            if (limit != Integer.MAX_VALUE) {
                showShortItems();
            }
        }
    });
    getWindow().setAttributes(params);
}

From source file:co.mrktplaces.android.ui.views.smarttablayout.SmartTabLayout.java

public SmartTabLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Disable the Scroll Bar
    setHorizontalScrollBarEnabled(false);

    final DisplayMetrics dm = getResources().getDisplayMetrics();
    final float density = dm.density;

    int tabBackgroundResId = NO_ID;
    int textHorizontalPadding = (int) (TAB_VIEW_PADDING_DIPS * density);
    int textMinWidth = (int) (TAB_VIEW_TEXT_MIN_WIDTH * density);
    boolean distributeEvenly = DEFAULT_DISTRIBUTE_EVENLY;
    int customTabLayoutId = NO_ID;
    int customTabTextViewId = NO_ID;
    boolean clickable = TAB_CLICKABLE;
    int titleOffset = (int) (TITLE_OFFSET_DIPS * density);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.stl_SmartTabLayout, defStyle, 0);
    tabBackgroundResId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_defaultTabBackground,
            tabBackgroundResId);//  w w w .  j  av a  2 s .c o  m
    textHorizontalPadding = a.getDimensionPixelSize(
            R.styleable.stl_SmartTabLayout_stl_defaultTabTextHorizontalPadding, textHorizontalPadding);
    textMinWidth = a.getDimensionPixelSize(R.styleable.stl_SmartTabLayout_stl_defaultTabTextMinWidth,
            textMinWidth);
    customTabLayoutId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextLayoutId,
            customTabLayoutId);
    customTabTextViewId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextViewId,
            customTabTextViewId);
    distributeEvenly = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_distributeEvenly, distributeEvenly);
    clickable = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_clickable, clickable);
    titleOffset = a.getLayoutDimension(R.styleable.stl_SmartTabLayout_stl_titleOffset, titleOffset);
    a.recycle();

    this.titleOffset = titleOffset;
    this.tabViewBackgroundResId = tabBackgroundResId;
    this.tabViewTextHorizontalPadding = textHorizontalPadding;
    this.tabViewTextMinWidth = textMinWidth;
    this.internalTabClickListener = clickable ? new InternalTabClickListener() : null;
    this.distributeEvenly = distributeEvenly;

    if (customTabLayoutId != NO_ID) {
        setCustomTabView(customTabLayoutId, customTabTextViewId);
    }

    this.tabStrip = new SmartTabStrip(context, attrs);

    if (distributeEvenly && tabStrip.isIndicatorAlwaysInCenter()) {
        throw new UnsupportedOperationException(
                "'distributeEvenly' and 'indicatorAlwaysInCenter' both use does not support");
    }

    // Make sure that the Tab Strips fills this View
    setFillViewport(!tabStrip.isIndicatorAlwaysInCenter());

    addView(tabStrip, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

}

From source file:com.it520.activity.main.wight.SmartTabLayout.java

public SmartTabLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Disable the Scroll Bar
    setHorizontalScrollBarEnabled(false);

    final DisplayMetrics dm = getResources().getDisplayMetrics();
    final float density = dm.density;

    int tabBackgroundResId = NO_ID;
    boolean textAllCaps = TAB_VIEW_TEXT_ALL_CAPS;
    ColorStateList textColors;//from   w w  w .  j  a  va 2  s  . c  o m
    float textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP, dm);
    int textHorizontalPadding = (int) (TAB_VIEW_PADDING_DIPS * density);
    int textMinWidth = (int) (TAB_VIEW_TEXT_MIN_WIDTH * density);
    boolean distributeEvenly = DEFAULT_DISTRIBUTE_EVENLY;
    int customTabLayoutId = NO_ID;
    int customTabTextViewId = NO_ID;
    boolean clickable = TAB_CLICKABLE;
    int titleOffset = (int) (TITLE_OFFSET_DIPS * density);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.stl_SmartTabLayout, defStyle, 0);
    tabBackgroundResId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_defaultTabBackground,
            tabBackgroundResId);
    textAllCaps = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_defaultTabTextAllCaps, textAllCaps);
    textColors = a.getColorStateList(R.styleable.stl_SmartTabLayout_stl_defaultTabTextColor);
    textSize = a.getDimension(R.styleable.stl_SmartTabLayout_stl_defaultTabTextSize, textSize);
    textHorizontalPadding = a.getDimensionPixelSize(
            R.styleable.stl_SmartTabLayout_stl_defaultTabTextHorizontalPadding, textHorizontalPadding);
    textMinWidth = a.getDimensionPixelSize(R.styleable.stl_SmartTabLayout_stl_defaultTabTextMinWidth,
            textMinWidth);
    customTabLayoutId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextLayoutId,
            customTabLayoutId);
    customTabTextViewId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextViewId,
            customTabTextViewId);
    distributeEvenly = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_distributeEvenly, distributeEvenly);
    clickable = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_clickable, clickable);
    titleOffset = a.getLayoutDimension(R.styleable.stl_SmartTabLayout_stl_titleOffset, titleOffset);
    a.recycle();

    this.titleOffset = titleOffset;
    this.tabViewBackgroundResId = tabBackgroundResId;
    this.tabViewTextAllCaps = textAllCaps;
    this.tabViewTextColors = (textColors != null) ? textColors : ColorStateList.valueOf(TAB_VIEW_TEXT_COLOR);
    this.tabViewTextSize = textSize;
    this.tabViewTextHorizontalPadding = textHorizontalPadding;
    this.tabViewTextMinWidth = textMinWidth;
    this.internalTabClickListener = clickable ? new InternalTabClickListener() : null;
    this.distributeEvenly = distributeEvenly;

    if (customTabLayoutId != NO_ID) {
        setCustomTabView(customTabLayoutId, customTabTextViewId);
    }

    this.tabStrip = new SmartTabStrip(context, attrs);

    if (distributeEvenly && tabStrip.isIndicatorAlwaysInCenter()) {
        throw new UnsupportedOperationException(
                "'distributeEvenly' and 'indicatorAlwaysInCenter' both use does not support");
    }

    // Make sure that the Tab Strips fills this View
    setFillViewport(!tabStrip.isIndicatorAlwaysInCenter());

    addView(tabStrip, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

}

From source file:com.shine.demo.viewpager.smartTabLayout.SmartTabLayout.java

public SmartTabLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Disable the Scroll Bar
    setHorizontalScrollBarEnabled(false);

    final DisplayMetrics dm = getResources().getDisplayMetrics();
    final float density = dm.density;

    int tabBackgroundResId = NO_ID;
    boolean textAllCaps = TAB_VIEW_TEXT_ALL_CAPS;
    ColorStateList textColors;/*from   w  w w . jav a  2 s.c om*/
    float textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP, dm);
    int textHorizontalPadding = (int) (TAB_VIEW_PADDING_DIPS * density);
    int textMinWidth = (int) (TAB_VIEW_TEXT_MIN_WIDTH * density);
    boolean distributeEvenly = DEFAULT_DISTRIBUTE_EVENLY;
    int customTabLayoutId = NO_ID;
    int customTabTextViewId = NO_ID;
    boolean clickable = TAB_CLICKABLE;
    int titleOffset = (int) (TITLE_OFFSET_DIPS * density);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.stl_SmartTabLayout, defStyle, 0);
    tabBackgroundResId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_defaultTabBackground,
            tabBackgroundResId);
    textAllCaps = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_defaultTabTextAllCaps, textAllCaps);
    textColors = a.getColorStateList(R.styleable.stl_SmartTabLayout_stl_defaultTabTextColor);
    textSize = a.getDimension(R.styleable.stl_SmartTabLayout_stl_defaultTabTextSize, textSize);
    textHorizontalPadding = a.getDimensionPixelSize(
            R.styleable.stl_SmartTabLayout_stl_defaultTabTextHorizontalPadding, textHorizontalPadding);
    textMinWidth = a.getDimensionPixelSize(R.styleable.stl_SmartTabLayout_stl_defaultTabTextMinWidth,
            textMinWidth);
    customTabLayoutId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextLayoutId,
            customTabLayoutId);
    customTabTextViewId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextViewId,
            customTabTextViewId);
    distributeEvenly = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_distributeEvenly, distributeEvenly);
    clickable = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_clickable, clickable);
    titleOffset = a.getLayoutDimension(R.styleable.stl_SmartTabLayout_stl_titleOffset, titleOffset);
    a.recycle();

    this.titleOffset = titleOffset;
    this.tabViewBackgroundResId = tabBackgroundResId;
    this.tabViewTextAllCaps = textAllCaps;
    this.tabViewTextColors = (textColors != null) ? textColors : ColorStateList.valueOf(TAB_VIEW_TEXT_COLOR);
    this.tabViewTextSize = textSize;
    this.tabViewTextHorizontalPadding = textHorizontalPadding;
    this.tabViewTextMinWidth = textMinWidth;
    this.internalTabClickListener = clickable ? new InternalTabClickListener() : null;
    this.distributeEvenly = distributeEvenly;

    if (customTabLayoutId != NO_ID) {
        setCustomTabView(customTabLayoutId, customTabTextViewId);
    }

    this.tabStrip = new SmartTabStrip(context, attrs);

    if (distributeEvenly && tabStrip.isIndicatorAlwaysInCenter()) {
        throw new UnsupportedOperationException(
                "'distributeEvenly' and 'indicatorAlwaysInCenter' both use does not support");
    }

    this.tabViewTextColors = new ColorStateList(
            new int[][] { new int[] { android.R.attr.state_pressed },
                    new int[] { android.R.attr.state_selected }, new int[] {} },
            new int[] { Color.rgb(255, 111, 51), Color.rgb(255, 111, 51), Color.parseColor("#222222") });

    // Make sure that the Tab Strips fills this View
    setFillViewport(!tabStrip.isIndicatorAlwaysInCenter());

    addView(tabStrip, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

}

From source file:com.simplealertdialog.SimpleAlertDialog.java

private void obtainStyles() {
    TypedArray a = getContext().getTheme().obtainStyledAttributes(null, R.styleable.SimpleAlertDialogStyle,
            R.attr.simpleAlertDialogStyle, R.style.Theme_SimpleAlertDialog);

    mListChoiceIndicatorSingle = a//from  ww w.j  a v a 2 s  . c  o  m
            .getResourceId(R.styleable.SimpleAlertDialogStyle_sadListChoiceIndicatorSingle, 0);
    mTitleTextStyle = a.getResourceId(R.styleable.SimpleAlertDialogStyle_sadTitleTextStyle, 0);
    mMessageTextStyle = a.getResourceId(R.styleable.SimpleAlertDialogStyle_sadMessageTextStyle, 0);
    mButtonTextStyle = a.getResourceId(R.styleable.SimpleAlertDialogStyle_sadButtonTextStyle, 0);
    mListItemTextStyle = a.getResourceId(R.styleable.SimpleAlertDialogStyle_sadListItemTextStyle, 0);
    mListSelectorBackground = a.getDrawable(R.styleable.SimpleAlertDialogStyle_sadListSelectorBackground);
    mTitleSeparatorBackground = a.getDrawable(R.styleable.SimpleAlertDialogStyle_sadTitleSeparatorBackground);
    mTitleSeparatorHeight = a.getLayoutDimension(R.styleable.SimpleAlertDialogStyle_sadTitleSeparatorHeight,
            getContext().getResources().getDimensionPixelSize(R.dimen.sad__dialog_title_separator_height));
    mButtonTopDividerBackground = a
            .getDrawable(R.styleable.SimpleAlertDialogStyle_sadButtonTopDividerBackground);
    mButtonVerticalDividerBackground = a
            .getDrawable(R.styleable.SimpleAlertDialogStyle_sadButtonVerticalDividerBackground);
    mBackgroundFull = a.getDrawable(R.styleable.SimpleAlertDialogStyle_sadBackgroundFull);
    mBackgroundTop = a.getDrawable(R.styleable.SimpleAlertDialogStyle_sadBackgroundTop);
    mBackgroundMiddle = a.getDrawable(R.styleable.SimpleAlertDialogStyle_sadBackgroundMiddle);
    mBackgroundBottom = a.getDrawable(R.styleable.SimpleAlertDialogStyle_sadBackgroundBottom);

    a.recycle();
}

From source file:com.facebook.litho.InternalNode.java

void applyAttributes(TypedArray a) {
    for (int i = 0, size = a.getIndexCount(); i < size; i++) {
        final int attr = a.getIndex(i);

        if (attr == R.styleable.ComponentLayout_android_layout_width) {
            int width = a.getLayoutDimension(attr, -1);
            // We don't support WRAP_CONTENT or MATCH_PARENT so no-op for them
            if (width >= 0) {
                widthPx(width);// w w w .  j a  v  a2 s  . c om
            }
        } else if (attr == R.styleable.ComponentLayout_android_layout_height) {
            int height = a.getLayoutDimension(attr, -1);
            // We don't support WRAP_CONTENT or MATCH_PARENT so no-op for them
            if (height >= 0) {
                heightPx(height);
            }
        } else if (attr == R.styleable.ComponentLayout_android_paddingLeft) {
            paddingPx(LEFT, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_paddingTop) {
            paddingPx(TOP, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_paddingRight) {
            paddingPx(RIGHT, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_paddingBottom) {
            paddingPx(BOTTOM, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_paddingStart && SUPPORTS_RTL) {
            paddingPx(START, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_paddingEnd && SUPPORTS_RTL) {
            paddingPx(END, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_padding) {
            paddingPx(ALL, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_layout_marginLeft) {
            marginPx(LEFT, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_layout_marginTop) {
            marginPx(TOP, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_layout_marginRight) {
            marginPx(RIGHT, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_layout_marginBottom) {
            marginPx(BOTTOM, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_layout_marginStart && SUPPORTS_RTL) {
            marginPx(START, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_layout_marginEnd && SUPPORTS_RTL) {
            marginPx(END, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_layout_margin) {
            marginPx(ALL, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_importantForAccessibility
                && SDK_INT >= JELLY_BEAN) {
            importantForAccessibility(a.getInt(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_android_duplicateParentState) {
            duplicateParentState(a.getBoolean(attr, false));
        } else if (attr == R.styleable.ComponentLayout_android_background) {
            if (TypedArrayUtils.isColorAttribute(a, R.styleable.ComponentLayout_android_background)) {
                backgroundColor(a.getColor(attr, 0));
            } else {
                backgroundRes(a.getResourceId(attr, -1));
            }
        } else if (attr == R.styleable.ComponentLayout_android_foreground) {
            if (TypedArrayUtils.isColorAttribute(a, R.styleable.ComponentLayout_android_foreground)) {
                foregroundColor(a.getColor(attr, 0));
            } else {
                foregroundRes(a.getResourceId(attr, -1));
            }
        } else if (attr == R.styleable.ComponentLayout_android_contentDescription) {
            contentDescription(a.getString(attr));
        } else if (attr == R.styleable.ComponentLayout_flex_direction) {
            flexDirection(YogaFlexDirection.fromInt(a.getInteger(attr, 0)));
        } else if (attr == R.styleable.ComponentLayout_flex_wrap) {
            wrap(YogaWrap.fromInt(a.getInteger(attr, 0)));
        } else if (attr == R.styleable.ComponentLayout_flex_justifyContent) {
            justifyContent(YogaJustify.fromInt(a.getInteger(attr, 0)));
        } else if (attr == R.styleable.ComponentLayout_flex_alignItems) {
            alignItems(YogaAlign.fromInt(a.getInteger(attr, 0)));
        } else if (attr == R.styleable.ComponentLayout_flex_alignSelf) {
            alignSelf(YogaAlign.fromInt(a.getInteger(attr, 0)));
        } else if (attr == R.styleable.ComponentLayout_flex_positionType) {
            positionType(YogaPositionType.fromInt(a.getInteger(attr, 0)));
        } else if (attr == R.styleable.ComponentLayout_flex) {
            final float flex = a.getFloat(attr, -1);
            if (flex >= 0f) {
                flex(flex);
            }
        } else if (attr == R.styleable.ComponentLayout_flex_left) {
            positionPx(LEFT, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_flex_top) {
            positionPx(TOP, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_flex_right) {
            positionPx(RIGHT, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_flex_bottom) {
            positionPx(BOTTOM, a.getDimensionPixelOffset(attr, 0));
        } else if (attr == R.styleable.ComponentLayout_flex_layoutDirection) {
            final int layoutDirection = a.getInteger(attr, -1);
            layoutDirection(YogaDirection.fromInt(layoutDirection));
        }
    }
}