Created
December 17, 2016 08:13
-
-
Save selvan/c3c820cf4314cc6f45da422df79c6c51 to your computer and use it in GitHub Desktop.
Yoga Layout engine - HelloWorld
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.facebook.yoga.*; | |
public class HelloWorld { | |
public static void main(String s[]) { | |
YogaNode root = new YogaNode(); | |
root.setWidth(500); | |
root.setHeight(300); | |
root.setAlignItems(YogaAlign.CENTER); | |
root.setJustifyContent(YogaJustify.CENTER); | |
root.setPadding(YogaEdge.ALL, 20); | |
YogaNode text = new YogaNode(); | |
text.setWidth(200); | |
text.setHeight(25); | |
YogaNode image = new YogaNode(); | |
image.setWidth(50); | |
image.setHeight(50); | |
image.setPositionType(YogaPositionType.ABSOLUTE); | |
image.setPosition(YogaEdge.END, 20); | |
image.setPosition(YogaEdge.TOP, 20); | |
root.addChildAt(text, 0); | |
root.addChildAt(image, 1); | |
root.calculateLayout(); | |
System.out.format("%n Position of text node (%.3f, %.3f) %n", text.getLayoutX(), text.getLayoutY()); | |
System.out.format("%n Position of image node (%.3f, %.3f) %n", image.getLayoutX(), image.getLayoutY()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment