Add yg prefix to attributes

Summary: To avoid clashes in the `app:` namespace, we prefix all yoga attributes with `yg_`.

Reviewed By: emilsjolander

Differential Revision: D4643080

fbshipit-source-id: 3e9265fd57e56a1df2f687a5d17c5bc66b8befa3
This commit is contained in:
Robert Spencer
2017-03-03 00:30:42 -08:00
committed by Facebook Github Bot
parent 6336e641f4
commit 7047d96087
3 changed files with 237 additions and 236 deletions

View File

@@ -18,120 +18,120 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/sample_children_background" android:background="@drawable/sample_children_background"
yoga:margin_horizontal="10dp" yoga:yg_margin_horizontal="10dp"
yoga:margin_top="5dp" yoga:yg_margin_top="5dp"
yoga:flex_direction="row" yoga:yg_flex_direction="row"
yoga:align_items="center" yoga:yg_align_items="center"
> >
<ImageView <ImageView
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:src="@drawable/ic_launcher" android:src="@drawable/ic_launcher"
yoga:flex="0" yoga:yg_flex="0"
/> />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/child_1_text" android:text="@string/child_1_text"
android:textColor="@color/children_text" android:textColor="@color/children_text"
yoga:flex="1" yoga:yg_flex="1"
yoga:margin_start="8dp" yoga:yg_margin_start="8dp"
/> />
</YogaLayout> </YogaLayout>
<YogaLayout <YogaLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/sample_children_background" android:background="@drawable/sample_children_background"
yoga:margin_horizontal="10dp" yoga:yg_margin_horizontal="10dp"
yoga:margin_top="5dp" yoga:yg_margin_top="5dp"
yoga:flex_direction="row" yoga:yg_flex_direction="row"
yoga:align_items="center" yoga:yg_align_items="center"
> >
<ImageView <ImageView
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:src="@drawable/ic_launcher" android:src="@drawable/ic_launcher"
yoga:flex="0" yoga:yg_flex="0"
/> />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/child_2_text" android:text="@string/child_2_text"
android:textColor="@color/children_text" android:textColor="@color/children_text"
yoga:flex="1" yoga:yg_flex="1"
yoga:margin_start="8dp" yoga:yg_margin_start="8dp"
/> />
</YogaLayout> </YogaLayout>
<YogaLayout <YogaLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/sample_children_background" android:background="@drawable/sample_children_background"
yoga:margin_horizontal="10dp" yoga:yg_margin_horizontal="10dp"
yoga:margin_top="5dp" yoga:yg_margin_top="5dp"
yoga:flex_direction="row" yoga:yg_flex_direction="row"
yoga:align_items="center" yoga:yg_align_items="center"
> >
<ImageView <ImageView
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:src="@drawable/ic_launcher" android:src="@drawable/ic_launcher"
yoga:flex="0" yoga:yg_flex="0"
/> />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/child_3_text" android:text="@string/child_3_text"
android:textColor="@color/children_text" android:textColor="@color/children_text"
yoga:flex="1" yoga:yg_flex="1"
yoga:margin_start="8dp" yoga:yg_margin_start="8dp"
/> />
</YogaLayout> </YogaLayout>
<YogaLayout <YogaLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/sample_children_background" android:background="@drawable/sample_children_background"
yoga:margin_horizontal="10dp" yoga:yg_margin_horizontal="10dp"
yoga:margin_top="5dp" yoga:yg_margin_top="5dp"
yoga:flex_direction="row" yoga:yg_flex_direction="row"
yoga:align_items="center" yoga:yg_align_items="center"
> >
<ImageView <ImageView
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:src="@drawable/ic_launcher" android:src="@drawable/ic_launcher"
yoga:flex="0" yoga:yg_flex="0"
/> />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/child_4_text" android:text="@string/child_4_text"
android:textColor="@color/children_text" android:textColor="@color/children_text"
yoga:flex="1" yoga:yg_flex="1"
yoga:margin_start="8dp" yoga:yg_margin_start="8dp"
/> />
</YogaLayout> </YogaLayout>
<YogaLayout <YogaLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/sample_children_background" android:background="@drawable/sample_children_background"
yoga:margin_horizontal="10dp" yoga:yg_margin_horizontal="10dp"
yoga:margin_top="5dp" yoga:yg_margin_top="5dp"
yoga:flex_direction="row" yoga:yg_flex_direction="row"
yoga:align_items="center" yoga:yg_align_items="center"
> >
<ImageView <ImageView
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:src="@drawable/ic_launcher" android:src="@drawable/ic_launcher"
yoga:flex="0" yoga:yg_flex="0"
/> />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/child_5_text" android:text="@string/child_5_text"
android:textColor="@color/children_text" android:textColor="@color/children_text"
yoga:flex="1" yoga:yg_flex="1"
yoga:margin_start="10dp" yoga:yg_margin_start="10dp"
/> />
</YogaLayout> </YogaLayout>
</YogaLayout> </YogaLayout>

View File

@@ -403,187 +403,187 @@ public class YogaLayout extends ViewGroup {
final int attribute = layoutParameters.numericAttributes.keyAt(i); final int attribute = layoutParameters.numericAttributes.keyAt(i);
final float value = layoutParameters.numericAttributes.valueAt(i); final float value = layoutParameters.numericAttributes.valueAt(i);
if (attribute == R.styleable.yoga_align_content) { if (attribute == R.styleable.yoga_yg_align_content) {
node.setAlignContent(YogaAlign.fromInt(Math.round(value))); node.setAlignContent(YogaAlign.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_align_items) { } else if (attribute == R.styleable.yoga_yg_align_items) {
node.setAlignItems(YogaAlign.fromInt(Math.round(value))); node.setAlignItems(YogaAlign.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_align_self) { } else if (attribute == R.styleable.yoga_yg_align_self) {
node.setAlignSelf(YogaAlign.fromInt(Math.round(value))); node.setAlignSelf(YogaAlign.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_aspect_ratio) { } else if (attribute == R.styleable.yoga_yg_aspect_ratio) {
node.setAspectRatio(value); node.setAspectRatio(value);
} else if (attribute == R.styleable.yoga_border_left) { } else if (attribute == R.styleable.yoga_yg_border_left) {
node.setBorder(YogaEdge.LEFT, value); node.setBorder(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_border_top) { } else if (attribute == R.styleable.yoga_yg_border_top) {
node.setBorder(YogaEdge.TOP, value); node.setBorder(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_border_right) { } else if (attribute == R.styleable.yoga_yg_border_right) {
node.setBorder(YogaEdge.RIGHT, value); node.setBorder(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_border_bottom) { } else if (attribute == R.styleable.yoga_yg_border_bottom) {
node.setBorder(YogaEdge.BOTTOM, value); node.setBorder(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_border_start) { } else if (attribute == R.styleable.yoga_yg_border_start) {
node.setBorder(YogaEdge.START, value); node.setBorder(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_border_end) { } else if (attribute == R.styleable.yoga_yg_border_end) {
node.setBorder(YogaEdge.END, value); node.setBorder(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_border_horizontal) { } else if (attribute == R.styleable.yoga_yg_border_horizontal) {
node.setBorder(YogaEdge.HORIZONTAL, value); node.setBorder(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_border_vertical) { } else if (attribute == R.styleable.yoga_yg_border_vertical) {
node.setBorder(YogaEdge.VERTICAL, value); node.setBorder(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_border_all) { } else if (attribute == R.styleable.yoga_yg_border_all) {
node.setBorder(YogaEdge.ALL, value); node.setBorder(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_direction) { } else if (attribute == R.styleable.yoga_yg_direction) {
node.setDirection(YogaDirection.fromInt(Math.round(value))); node.setDirection(YogaDirection.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_display) { } else if (attribute == R.styleable.yoga_yg_display) {
node.setDisplay(YogaDisplay.fromInt(Math.round(value))); node.setDisplay(YogaDisplay.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_flex) { } else if (attribute == R.styleable.yoga_yg_flex) {
node.setFlex(value); node.setFlex(value);
} else if (attribute == R.styleable.yoga_flex_basis) { } else if (attribute == R.styleable.yoga_yg_flex_basis) {
node.setFlexBasis(value); node.setFlexBasis(value);
} else if (attribute == R.styleable.yoga_flex_basis_percent) { } else if (attribute == R.styleable.yoga_yg_flex_basis_percent) {
node.setFlexBasisPercent(value); node.setFlexBasisPercent(value);
} else if (attribute == R.styleable.yoga_flex_direction) { } else if (attribute == R.styleable.yoga_yg_flex_direction) {
node.setFlexDirection(YogaFlexDirection.fromInt(Math.round(value))); node.setFlexDirection(YogaFlexDirection.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_flex_grow) { } else if (attribute == R.styleable.yoga_yg_flex_grow) {
node.setFlexGrow(value); node.setFlexGrow(value);
} else if (attribute == R.styleable.yoga_flex_shrink) { } else if (attribute == R.styleable.yoga_yg_flex_shrink) {
node.setFlexShrink(value); node.setFlexShrink(value);
} else if (attribute == R.styleable.yoga_height) { } else if (attribute == R.styleable.yoga_yg_height) {
node.setHeight(value); node.setHeight(value);
} else if (attribute == R.styleable.yoga_height_percent) { } else if (attribute == R.styleable.yoga_yg_height_percent) {
node.setHeightPercent(value); node.setHeightPercent(value);
} else if (attribute == R.styleable.yoga_margin_left) { } else if (attribute == R.styleable.yoga_yg_margin_left) {
node.setMargin(YogaEdge.LEFT, value); node.setMargin(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_justify_content) { } else if (attribute == R.styleable.yoga_yg_justify_content) {
node.setJustifyContent(YogaJustify.fromInt(Math.round(value))); node.setJustifyContent(YogaJustify.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_margin_top) { } else if (attribute == R.styleable.yoga_yg_margin_top) {
node.setMargin(YogaEdge.TOP, value); node.setMargin(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_margin_right) { } else if (attribute == R.styleable.yoga_yg_margin_right) {
node.setMargin(YogaEdge.RIGHT, value); node.setMargin(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_margin_bottom) { } else if (attribute == R.styleable.yoga_yg_margin_bottom) {
node.setMargin(YogaEdge.BOTTOM, value); node.setMargin(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_margin_start) { } else if (attribute == R.styleable.yoga_yg_margin_start) {
node.setMargin(YogaEdge.START, value); node.setMargin(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_margin_end) { } else if (attribute == R.styleable.yoga_yg_margin_end) {
node.setMargin(YogaEdge.END, value); node.setMargin(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_margin_horizontal) { } else if (attribute == R.styleable.yoga_yg_margin_horizontal) {
node.setMargin(YogaEdge.HORIZONTAL, value); node.setMargin(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_margin_vertical) { } else if (attribute == R.styleable.yoga_yg_margin_vertical) {
node.setMargin(YogaEdge.VERTICAL, value); node.setMargin(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_margin_all) { } else if (attribute == R.styleable.yoga_yg_margin_all) {
node.setMargin(YogaEdge.ALL, value); node.setMargin(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_margin_percent_left) { } else if (attribute == R.styleable.yoga_yg_margin_percent_left) {
node.setMarginPercent(YogaEdge.LEFT, value); node.setMarginPercent(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_margin_percent_top) { } else if (attribute == R.styleable.yoga_yg_margin_percent_top) {
node.setMarginPercent(YogaEdge.TOP, value); node.setMarginPercent(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_margin_percent_right) { } else if (attribute == R.styleable.yoga_yg_margin_percent_right) {
node.setMarginPercent(YogaEdge.RIGHT, value); node.setMarginPercent(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_margin_percent_bottom) { } else if (attribute == R.styleable.yoga_yg_margin_percent_bottom) {
node.setMarginPercent(YogaEdge.BOTTOM, value); node.setMarginPercent(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_margin_percent_start) { } else if (attribute == R.styleable.yoga_yg_margin_percent_start) {
node.setMarginPercent(YogaEdge.START, value); node.setMarginPercent(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_margin_percent_end) { } else if (attribute == R.styleable.yoga_yg_margin_percent_end) {
node.setMarginPercent(YogaEdge.END, value); node.setMarginPercent(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_margin_percent_horizontal) { } else if (attribute == R.styleable.yoga_yg_margin_percent_horizontal) {
node.setMarginPercent(YogaEdge.HORIZONTAL, value); node.setMarginPercent(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_margin_percent_vertical) { } else if (attribute == R.styleable.yoga_yg_margin_percent_vertical) {
node.setMarginPercent(YogaEdge.VERTICAL, value); node.setMarginPercent(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_margin_percent_all) { } else if (attribute == R.styleable.yoga_yg_margin_percent_all) {
node.setMarginPercent(YogaEdge.ALL, value); node.setMarginPercent(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_max_height) { } else if (attribute == R.styleable.yoga_yg_max_height) {
node.setMaxHeight(value); node.setMaxHeight(value);
} else if (attribute == R.styleable.yoga_max_height_percent) { } else if (attribute == R.styleable.yoga_yg_max_height_percent) {
node.setMaxHeightPercent(value); node.setMaxHeightPercent(value);
} else if (attribute == R.styleable.yoga_max_width) { } else if (attribute == R.styleable.yoga_yg_max_width) {
node.setMaxWidth(value); node.setMaxWidth(value);
} else if (attribute == R.styleable.yoga_max_width_percent) { } else if (attribute == R.styleable.yoga_yg_max_width_percent) {
node.setMaxWidthPercent(value); node.setMaxWidthPercent(value);
} else if (attribute == R.styleable.yoga_min_height) { } else if (attribute == R.styleable.yoga_yg_min_height) {
node.setMinHeight(value); node.setMinHeight(value);
} else if (attribute == R.styleable.yoga_min_height_percent) { } else if (attribute == R.styleable.yoga_yg_min_height_percent) {
node.setMinHeightPercent(value); node.setMinHeightPercent(value);
} else if (attribute == R.styleable.yoga_min_width) { } else if (attribute == R.styleable.yoga_yg_min_width) {
node.setMinWidth(value); node.setMinWidth(value);
} else if (attribute == R.styleable.yoga_min_width_percent) { } else if (attribute == R.styleable.yoga_yg_min_width_percent) {
node.setMinWidthPercent(value); node.setMinWidthPercent(value);
} else if (attribute == R.styleable.yoga_overflow) { } else if (attribute == R.styleable.yoga_yg_overflow) {
node.setOverflow(YogaOverflow.fromInt(Math.round(value))); node.setOverflow(YogaOverflow.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_padding_left) { } else if (attribute == R.styleable.yoga_yg_padding_left) {
node.setPadding(YogaEdge.LEFT, value); node.setPadding(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_padding_top) { } else if (attribute == R.styleable.yoga_yg_padding_top) {
node.setPadding(YogaEdge.TOP, value); node.setPadding(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_padding_right) { } else if (attribute == R.styleable.yoga_yg_padding_right) {
node.setPadding(YogaEdge.RIGHT, value); node.setPadding(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_padding_bottom) { } else if (attribute == R.styleable.yoga_yg_padding_bottom) {
node.setPadding(YogaEdge.BOTTOM, value); node.setPadding(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_padding_start) { } else if (attribute == R.styleable.yoga_yg_padding_start) {
node.setPadding(YogaEdge.START, value); node.setPadding(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_padding_end) { } else if (attribute == R.styleable.yoga_yg_padding_end) {
node.setPadding(YogaEdge.END, value); node.setPadding(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_padding_horizontal) { } else if (attribute == R.styleable.yoga_yg_padding_horizontal) {
node.setPadding(YogaEdge.HORIZONTAL, value); node.setPadding(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_padding_vertical) { } else if (attribute == R.styleable.yoga_yg_padding_vertical) {
node.setPadding(YogaEdge.VERTICAL, value); node.setPadding(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_padding_all) { } else if (attribute == R.styleable.yoga_yg_padding_all) {
node.setPadding(YogaEdge.ALL, value); node.setPadding(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_padding_percent_left) { } else if (attribute == R.styleable.yoga_yg_padding_percent_left) {
node.setPaddingPercent(YogaEdge.LEFT, value); node.setPaddingPercent(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_padding_percent_top) { } else if (attribute == R.styleable.yoga_yg_padding_percent_top) {
node.setPaddingPercent(YogaEdge.TOP, value); node.setPaddingPercent(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_padding_percent_right) { } else if (attribute == R.styleable.yoga_yg_padding_percent_right) {
node.setPaddingPercent(YogaEdge.RIGHT, value); node.setPaddingPercent(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_padding_percent_bottom) { } else if (attribute == R.styleable.yoga_yg_padding_percent_bottom) {
node.setPaddingPercent(YogaEdge.BOTTOM, value); node.setPaddingPercent(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_padding_percent_start) { } else if (attribute == R.styleable.yoga_yg_padding_percent_start) {
node.setPaddingPercent(YogaEdge.START, value); node.setPaddingPercent(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_padding_percent_end) { } else if (attribute == R.styleable.yoga_yg_padding_percent_end) {
node.setPaddingPercent(YogaEdge.END, value); node.setPaddingPercent(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_padding_percent_horizontal) { } else if (attribute == R.styleable.yoga_yg_padding_percent_horizontal) {
node.setPaddingPercent(YogaEdge.HORIZONTAL, value); node.setPaddingPercent(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_padding_percent_vertical) { } else if (attribute == R.styleable.yoga_yg_padding_percent_vertical) {
node.setPaddingPercent(YogaEdge.VERTICAL, value); node.setPaddingPercent(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_padding_percent_all) { } else if (attribute == R.styleable.yoga_yg_padding_percent_all) {
node.setPaddingPercent(YogaEdge.ALL, value); node.setPaddingPercent(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_position_left) { } else if (attribute == R.styleable.yoga_yg_position_left) {
node.setPosition(YogaEdge.LEFT, value); node.setPosition(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_position_top) { } else if (attribute == R.styleable.yoga_yg_position_top) {
node.setPosition(YogaEdge.TOP, value); node.setPosition(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_position_right) { } else if (attribute == R.styleable.yoga_yg_position_right) {
node.setPosition(YogaEdge.RIGHT, value); node.setPosition(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_position_bottom) { } else if (attribute == R.styleable.yoga_yg_position_bottom) {
node.setPosition(YogaEdge.BOTTOM, value); node.setPosition(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_position_start) { } else if (attribute == R.styleable.yoga_yg_position_start) {
node.setPosition(YogaEdge.START, value); node.setPosition(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_position_end) { } else if (attribute == R.styleable.yoga_yg_position_end) {
node.setPosition(YogaEdge.END, value); node.setPosition(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_position_horizontal) { } else if (attribute == R.styleable.yoga_yg_position_horizontal) {
node.setPosition(YogaEdge.HORIZONTAL, value); node.setPosition(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_position_vertical) { } else if (attribute == R.styleable.yoga_yg_position_vertical) {
node.setPosition(YogaEdge.VERTICAL, value); node.setPosition(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_position_all) { } else if (attribute == R.styleable.yoga_yg_position_all) {
node.setPosition(YogaEdge.ALL, value); node.setPosition(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_position_percent_left) { } else if (attribute == R.styleable.yoga_yg_position_percent_left) {
node.setPositionPercent(YogaEdge.LEFT, value); node.setPositionPercent(YogaEdge.LEFT, value);
} else if (attribute == R.styleable.yoga_position_percent_top) { } else if (attribute == R.styleable.yoga_yg_position_percent_top) {
node.setPositionPercent(YogaEdge.TOP, value); node.setPositionPercent(YogaEdge.TOP, value);
} else if (attribute == R.styleable.yoga_position_percent_right) { } else if (attribute == R.styleable.yoga_yg_position_percent_right) {
node.setPositionPercent(YogaEdge.RIGHT, value); node.setPositionPercent(YogaEdge.RIGHT, value);
} else if (attribute == R.styleable.yoga_position_percent_bottom) { } else if (attribute == R.styleable.yoga_yg_position_percent_bottom) {
node.setPositionPercent(YogaEdge.BOTTOM, value); node.setPositionPercent(YogaEdge.BOTTOM, value);
} else if (attribute == R.styleable.yoga_position_percent_start) { } else if (attribute == R.styleable.yoga_yg_position_percent_start) {
node.setPositionPercent(YogaEdge.START, value); node.setPositionPercent(YogaEdge.START, value);
} else if (attribute == R.styleable.yoga_position_percent_end) { } else if (attribute == R.styleable.yoga_yg_position_percent_end) {
node.setPositionPercent(YogaEdge.END, value); node.setPositionPercent(YogaEdge.END, value);
} else if (attribute == R.styleable.yoga_position_percent_horizontal) { } else if (attribute == R.styleable.yoga_yg_position_percent_horizontal) {
node.setPositionPercent(YogaEdge.HORIZONTAL, value); node.setPositionPercent(YogaEdge.HORIZONTAL, value);
} else if (attribute == R.styleable.yoga_position_percent_vertical) { } else if (attribute == R.styleable.yoga_yg_position_percent_vertical) {
node.setPositionPercent(YogaEdge.VERTICAL, value); node.setPositionPercent(YogaEdge.VERTICAL, value);
} else if (attribute == R.styleable.yoga_position_percent_all) { } else if (attribute == R.styleable.yoga_yg_position_percent_all) {
node.setPositionPercent(YogaEdge.ALL, value); node.setPositionPercent(YogaEdge.ALL, value);
} else if (attribute == R.styleable.yoga_position_type) { } else if (attribute == R.styleable.yoga_yg_position_type) {
node.setPositionType(YogaPositionType.fromInt(Math.round(value))); node.setPositionType(YogaPositionType.fromInt(Math.round(value)));
} else if (attribute == R.styleable.yoga_width) { } else if (attribute == R.styleable.yoga_yg_width) {
node.setWidth(value); node.setWidth(value);
} else if (attribute == R.styleable.yoga_width_percent) { } else if (attribute == R.styleable.yoga_yg_width_percent) {
node.setWidthPercent(value); node.setWidthPercent(value);
} else if (attribute == R.styleable.yoga_wrap) { } else if (attribute == R.styleable.yoga_yg_wrap) {
node.setWrap(YogaWrap.fromInt(Math.round(value))); node.setWrap(YogaWrap.fromInt(Math.round(value)));
} }
} }
@@ -593,23 +593,23 @@ public class YogaLayout extends ViewGroup {
final String value = layoutParameters.stringAttributes.valueAt(i); final String value = layoutParameters.stringAttributes.valueAt(i);
if (value.equals("auto")) { if (value.equals("auto")) {
if (attribute == R.styleable.yoga_margin_left) { if (attribute == R.styleable.yoga_yg_margin_left) {
node.setMarginAuto(YogaEdge.LEFT); node.setMarginAuto(YogaEdge.LEFT);
} else if (attribute == R.styleable.yoga_margin_top) { } else if (attribute == R.styleable.yoga_yg_margin_top) {
node.setMarginAuto(YogaEdge.TOP); node.setMarginAuto(YogaEdge.TOP);
} else if (attribute == R.styleable.yoga_margin_right) { } else if (attribute == R.styleable.yoga_yg_margin_right) {
node.setMarginAuto(YogaEdge.RIGHT); node.setMarginAuto(YogaEdge.RIGHT);
} else if (attribute == R.styleable.yoga_margin_bottom) { } else if (attribute == R.styleable.yoga_yg_margin_bottom) {
node.setMarginAuto(YogaEdge.BOTTOM); node.setMarginAuto(YogaEdge.BOTTOM);
} else if (attribute == R.styleable.yoga_margin_start) { } else if (attribute == R.styleable.yoga_yg_margin_start) {
node.setMarginAuto(YogaEdge.START); node.setMarginAuto(YogaEdge.START);
} else if (attribute == R.styleable.yoga_margin_end) { } else if (attribute == R.styleable.yoga_yg_margin_end) {
node.setMarginAuto(YogaEdge.END); node.setMarginAuto(YogaEdge.END);
} else if (attribute == R.styleable.yoga_margin_horizontal) { } else if (attribute == R.styleable.yoga_yg_margin_horizontal) {
node.setMarginAuto(YogaEdge.HORIZONTAL); node.setMarginAuto(YogaEdge.HORIZONTAL);
} else if (attribute == R.styleable.yoga_margin_vertical) { } else if (attribute == R.styleable.yoga_yg_margin_vertical) {
node.setMarginAuto(YogaEdge.VERTICAL); node.setMarginAuto(YogaEdge.VERTICAL);
} else if (attribute == R.styleable.yoga_margin_all) { } else if (attribute == R.styleable.yoga_yg_margin_all) {
node.setMarginAuto(YogaEdge.ALL); node.setMarginAuto(YogaEdge.ALL);
} }
} }
@@ -643,13 +643,14 @@ public class YogaLayout extends ViewGroup {
* *
* <p> * <p>
* This is actually mostly a wrapper around a {@code SparseArray} that holds a mapping between * This is actually mostly a wrapper around a {@code SparseArray} that holds a mapping between
* styleable id's ({@code R.styleable.yoga_*}) and the float of their values. In cases where the * styleable id's ({@code R.styleable.yoga_yg_*}) and the float of their values. In cases where
* value is an enum or an integer, they should first be cast to int (with rounding) before using. * the value is an enum or an integer, they should first be cast to int (with rounding) before
* using.
*/ */
public static class LayoutParams extends ViewGroup.LayoutParams { public static class LayoutParams extends ViewGroup.LayoutParams {
/** /**
* A mapping from attribute keys ({@code R.styleable.yoga_*}) to the float of their values. * A mapping from attribute keys ({@code R.styleable.yoga_yg_*}) to the float of their values.
* For attributes like position_percent_left (float), this is the native type. For attributes * For attributes like position_percent_left (float), this is the native type. For attributes
* like align_self (enums), the integer enum value is cast (rounding is used on the other side * like align_self (enums), the integer enum value is cast (rounding is used on the other side
* to prevent precision errors). Dimension attributes are stored as float pixels. * to prevent precision errors). Dimension attributes are stored as float pixels.
@@ -657,7 +658,7 @@ public class YogaLayout extends ViewGroup {
SparseArray<Float> numericAttributes; SparseArray<Float> numericAttributes;
/** /**
* A mapping from attribute keys ({@code R.styleable.yoga_*}) with string values to those * A mapping from attribute keys ({@code R.styleable.yoga_yg_*}) with string values to those
* strings. This is used for values such as "auto". * strings. This is used for values such as "auto".
*/ */
SparseArray<String> stringAttributes; SparseArray<String> stringAttributes;
@@ -680,10 +681,10 @@ public class YogaLayout extends ViewGroup {
// Negative values include MATCH_PARENT and WRAP_CONTENT // Negative values include MATCH_PARENT and WRAP_CONTENT
if (source.width >= 0) { if (source.width >= 0) {
numericAttributes.put(R.styleable.yoga_width, (float) width); numericAttributes.put(R.styleable.yoga_yg_width, (float) width);
} }
if (source.height >= 0) { if (source.height >= 0) {
numericAttributes.put(R.styleable.yoga_height, (float) height); numericAttributes.put(R.styleable.yoga_yg_height, (float) height);
} }
} }
} }
@@ -706,10 +707,10 @@ public class YogaLayout extends ViewGroup {
stringAttributes = new SparseArray<>(); stringAttributes = new SparseArray<>();
// Negative values include MATCH_PARENT and WRAP_CONTENT // Negative values include MATCH_PARENT and WRAP_CONTENT
if (width >= 0) { if (width >= 0) {
numericAttributes.put(R.styleable.yoga_width, (float) width); numericAttributes.put(R.styleable.yoga_yg_width, (float) width);
} }
if (height >= 0) { if (height >= 0) {
numericAttributes.put(R.styleable.yoga_height, (float) height); numericAttributes.put(R.styleable.yoga_yg_height, (float) height);
} }
} }
@@ -728,10 +729,10 @@ public class YogaLayout extends ViewGroup {
// Negative values include MATCH_PARENT and WRAP_CONTENT // Negative values include MATCH_PARENT and WRAP_CONTENT
if (width >= 0) { if (width >= 0) {
numericAttributes.put(R.styleable.yoga_width, (float) width); numericAttributes.put(R.styleable.yoga_yg_width, (float) width);
} }
if (height >= 0) { if (height >= 0) {
numericAttributes.put(R.styleable.yoga_height, (float) height); numericAttributes.put(R.styleable.yoga_yg_height, (float) height);
} }
final int attributeCount = a.getIndexCount(); final int attributeCount = a.getIndexCount();

View File

@@ -12,7 +12,7 @@
<resources> <resources>
<declare-styleable name="yoga"> <declare-styleable name="yoga">
<attr name="align_content" format="enum"> <attr name="yg_align_content" format="enum">
<enum name="auto" value="0"/> <enum name="auto" value="0"/>
<enum name="flex_start" value="1"/> <enum name="flex_start" value="1"/>
<enum name="center" value="2"/> <enum name="center" value="2"/>
@@ -21,7 +21,7 @@
<enum name="baseline" value="5"/> <enum name="baseline" value="5"/>
</attr> </attr>
<attr name="align_items" format="enum"> <attr name="yg_align_items" format="enum">
<enum name="auto" value="0"/> <enum name="auto" value="0"/>
<enum name="flex_start" value="1"/> <enum name="flex_start" value="1"/>
<enum name="center" value="2"/> <enum name="center" value="2"/>
@@ -30,7 +30,7 @@
<enum name="baseline" value="5"/> <enum name="baseline" value="5"/>
</attr> </attr>
<attr name="align_self" format="enum"> <attr name="yg_align_self" format="enum">
<enum name="auto" value="0"/> <enum name="auto" value="0"/>
<enum name="flex_start" value="1"/> <enum name="flex_start" value="1"/>
<enum name="center" value="2"/> <enum name="center" value="2"/>
@@ -39,51 +39,51 @@
<enum name="baseline" value="5"/> <enum name="baseline" value="5"/>
</attr> </attr>
<attr name="aspect_ratio" format="float"/> <attr name="yg_aspect_ratio" format="float"/>
<attr name="border_left" format="dimension"/> <attr name="yg_border_left" format="dimension"/>
<attr name="border_top" format="dimension"/> <attr name="yg_border_top" format="dimension"/>
<attr name="border_right" format="dimension"/> <attr name="yg_border_right" format="dimension"/>
<attr name="border_bottom" format="dimension"/> <attr name="yg_border_bottom" format="dimension"/>
<attr name="border_start" format="dimension"/> <attr name="yg_border_start" format="dimension"/>
<attr name="border_end" format="dimension"/> <attr name="yg_border_end" format="dimension"/>
<attr name="border_horizontal" format="dimension"/> <attr name="yg_border_horizontal" format="dimension"/>
<attr name="border_vertical" format="dimension"/> <attr name="yg_border_vertical" format="dimension"/>
<attr name="border_all" format="dimension"/> <attr name="yg_border_all" format="dimension"/>
<attr name="direction" format="enum"> <attr name="yg_direction" format="enum">
<enum name="inherit" value="0"/> <enum name="inherit" value="0"/>
<enum name="ltr" value="1"/> <enum name="ltr" value="1"/>
<enum name="rtl" value="2"/> <enum name="rtl" value="2"/>
</attr> </attr>
<attr name="display" format="enum"> <attr name="yg_display" format="enum">
<enum name="flex" value="0"/> <enum name="flex" value="0"/>
<enum name="none" value="1"/> <enum name="none" value="1"/>
</attr> </attr>
<attr name="flex" format="float"/> <attr name="yg_flex" format="float"/>
<attr name="flex_basis" format="float"/> <attr name="yg_flex_basis" format="float"/>
<attr name="flex_basis_percent" format="float"/> <attr name="yg_flex_basis_percent" format="float"/>
<attr name="flex_direction" format="enum"> <attr name="yg_flex_direction" format="enum">
<enum name="column" value="0"/> <enum name="column" value="0"/>
<enum name="column_reverse" value="1"/> <enum name="column_reverse" value="1"/>
<enum name="row" value="2"/> <enum name="row" value="2"/>
<enum name="row_reverse" value="3"/> <enum name="row_reverse" value="3"/>
</attr> </attr>
<attr name="flex_grow" format="float"/> <attr name="yg_flex_grow" format="float"/>
<attr name="flex_shrink" format="float"/> <attr name="yg_flex_shrink" format="float"/>
<attr name="height" format="dimension"/> <attr name="yg_height" format="dimension"/>
<attr name="height_percent" format="float"/> <attr name="yg_height_percent" format="float"/>
<attr name="justify_content" format="enum"> <attr name="yg_justify_content" format="enum">
<enum name="flex_start" value="0"/> <enum name="flex_start" value="0"/>
<enum name="center" value="1"/> <enum name="center" value="1"/>
<enum name="flex_end" value="2"/> <enum name="flex_end" value="2"/>
@@ -91,98 +91,98 @@
<enum name="space_around" value="4"/> <enum name="space_around" value="4"/>
</attr> </attr>
<attr name="margin_left" format="dimension|string"/> <attr name="yg_margin_left" format="dimension|string"/>
<attr name="margin_top" format="dimension|string"/> <attr name="yg_margin_top" format="dimension|string"/>
<attr name="margin_right" format="dimension|string"/> <attr name="yg_margin_right" format="dimension|string"/>
<attr name="margin_bottom" format="dimension|string"/> <attr name="yg_margin_bottom" format="dimension|string"/>
<attr name="margin_start" format="dimension|string"/> <attr name="yg_margin_start" format="dimension|string"/>
<attr name="margin_end" format="dimension|string"/> <attr name="yg_margin_end" format="dimension|string"/>
<attr name="margin_horizontal" format="dimension|string"/> <attr name="yg_margin_horizontal" format="dimension|string"/>
<attr name="margin_vertical" format="dimension|string"/> <attr name="yg_margin_vertical" format="dimension|string"/>
<attr name="margin_all" format="dimension|string"/> <attr name="yg_margin_all" format="dimension|string"/>
<attr name="margin_percent_left" format="dimension"/> <attr name="yg_margin_percent_left" format="dimension"/>
<attr name="margin_percent_top" format="dimension"/> <attr name="yg_margin_percent_top" format="dimension"/>
<attr name="margin_percent_right" format="dimension"/> <attr name="yg_margin_percent_right" format="dimension"/>
<attr name="margin_percent_bottom" format="dimension"/> <attr name="yg_margin_percent_bottom" format="dimension"/>
<attr name="margin_percent_start" format="dimension"/> <attr name="yg_margin_percent_start" format="dimension"/>
<attr name="margin_percent_end" format="dimension"/> <attr name="yg_margin_percent_end" format="dimension"/>
<attr name="margin_percent_horizontal" format="dimension"/> <attr name="yg_margin_percent_horizontal" format="dimension"/>
<attr name="margin_percent_vertical" format="dimension"/> <attr name="yg_margin_percent_vertical" format="dimension"/>
<attr name="margin_percent_all" format="dimension"/> <attr name="yg_margin_percent_all" format="dimension"/>
<attr name="max_height" format="dimension"/> <attr name="yg_max_height" format="dimension"/>
<attr name="max_height_percent" format="float"/> <attr name="yg_max_height_percent" format="float"/>
<attr name="max_width" format="dimension"/> <attr name="yg_max_width" format="dimension"/>
<attr name="max_width_percent" format="float"/> <attr name="yg_max_width_percent" format="float"/>
<attr name="min_height" format="dimension"/> <attr name="yg_min_height" format="dimension"/>
<attr name="min_height_percent" format="float"/> <attr name="yg_min_height_percent" format="float"/>
<attr name="min_width" format="dimension"/> <attr name="yg_min_width" format="dimension"/>
<attr name="min_width_percent" format="float"/> <attr name="yg_min_width_percent" format="float"/>
<attr name="overflow" format="enum"> <attr name="yg_overflow" format="enum">
<enum name="visible" value="0"/> <enum name="visible" value="0"/>
<enum name="hidden" value="1"/> <enum name="hidden" value="1"/>
<enum name="scroll" value="2"/> <enum name="scroll" value="2"/>
</attr> </attr>
<attr name="padding_left" format="dimension"/> <attr name="yg_padding_left" format="dimension"/>
<attr name="padding_top" format="dimension"/> <attr name="yg_padding_top" format="dimension"/>
<attr name="padding_right" format="dimension"/> <attr name="yg_padding_right" format="dimension"/>
<attr name="padding_bottom" format="dimension"/> <attr name="yg_padding_bottom" format="dimension"/>
<attr name="padding_start" format="dimension"/> <attr name="yg_padding_start" format="dimension"/>
<attr name="padding_end" format="dimension"/> <attr name="yg_padding_end" format="dimension"/>
<attr name="padding_horizontal" format="dimension"/> <attr name="yg_padding_horizontal" format="dimension"/>
<attr name="padding_vertical" format="dimension"/> <attr name="yg_padding_vertical" format="dimension"/>
<attr name="padding_all" format="dimension"/> <attr name="yg_padding_all" format="dimension"/>
<attr name="padding_percent_left" format="float"/> <attr name="yg_padding_percent_left" format="float"/>
<attr name="padding_percent_top" format="float"/> <attr name="yg_padding_percent_top" format="float"/>
<attr name="padding_percent_right" format="float"/> <attr name="yg_padding_percent_right" format="float"/>
<attr name="padding_percent_bottom" format="float"/> <attr name="yg_padding_percent_bottom" format="float"/>
<attr name="padding_percent_start" format="float"/> <attr name="yg_padding_percent_start" format="float"/>
<attr name="padding_percent_end" format="float"/> <attr name="yg_padding_percent_end" format="float"/>
<attr name="padding_percent_horizontal" format="float"/> <attr name="yg_padding_percent_horizontal" format="float"/>
<attr name="padding_percent_vertical" format="float"/> <attr name="yg_padding_percent_vertical" format="float"/>
<attr name="padding_percent_all" format="float"/> <attr name="yg_padding_percent_all" format="float"/>
<attr name="position_left" format="dimension"/> <attr name="yg_position_left" format="dimension"/>
<attr name="position_top" format="dimension"/> <attr name="yg_position_top" format="dimension"/>
<attr name="position_right" format="dimension"/> <attr name="yg_position_right" format="dimension"/>
<attr name="position_bottom" format="dimension"/> <attr name="yg_position_bottom" format="dimension"/>
<attr name="position_start" format="dimension"/> <attr name="yg_position_start" format="dimension"/>
<attr name="position_end" format="dimension"/> <attr name="yg_position_end" format="dimension"/>
<attr name="position_horizontal" format="dimension"/> <attr name="yg_position_horizontal" format="dimension"/>
<attr name="position_vertical" format="dimension"/> <attr name="yg_position_vertical" format="dimension"/>
<attr name="position_all" format="dimension"/> <attr name="yg_position_all" format="dimension"/>
<attr name="position_percent_left" format="float"/> <attr name="yg_position_percent_left" format="float"/>
<attr name="position_percent_top" format="float"/> <attr name="yg_position_percent_top" format="float"/>
<attr name="position_percent_right" format="float"/> <attr name="yg_position_percent_right" format="float"/>
<attr name="position_percent_bottom" format="float"/> <attr name="yg_position_percent_bottom" format="float"/>
<attr name="position_percent_start" format="float"/> <attr name="yg_position_percent_start" format="float"/>
<attr name="position_percent_end" format="float"/> <attr name="yg_position_percent_end" format="float"/>
<attr name="position_percent_horizontal" format="float"/> <attr name="yg_position_percent_horizontal" format="float"/>
<attr name="position_percent_vertical" format="float"/> <attr name="yg_position_percent_vertical" format="float"/>
<attr name="position_percent_all" format="float"/> <attr name="yg_position_percent_all" format="float"/>
<attr name="position_type" format="enum"> <attr name="yg_position_type" format="enum">
<enum name="relative" value="0"/> <enum name="relative" value="0"/>
<enum name="absolute" value="1"/> <enum name="absolute" value="1"/>
</attr> </attr>
<attr name="width" format="dimension"/> <attr name="yg_width" format="dimension"/>
<attr name="width_percent" format="float"/> <attr name="yg_width_percent" format="float"/>
<attr name="wrap" format="enum"> <attr name="yg_wrap" format="enum">
<enum name="no_wrap" value="0"/> <enum name="no_wrap" value="0"/>
<enum name="wrap" value="1"/> <enum name="wrap" value="1"/>
</attr> </attr>