Summary: Adds docs for how to build the Android sample app and use the `YogaLayout`. Reviewed By: emilsjolander Differential Revision: D4557955 fbshipit-source-id: 49a3b8fde20de81a895244ffcecbd5bf392455b0
1.7 KiB
docid, title, layout, permalink
docid | title | layout | permalink |
---|---|---|---|
android | Android | docs | /docs/api/android/ |
There is an easy interface to Yoga called YogaLayout
. This is a view group that lays out its children using Yoga. We recommend looking at the sample app for details on its usage. However, as an overview you can simply define XML layouts such as
Note that there are some caveats, such as requiring the custom YogaLayoutViewFactory
in order to have tags YogaLayout
instead of com.facebook.samples.yoga.YogaLayout
.
layout_width and layout_height
If either are set to an actual size (in px or dp etc) then this is taken as a default for yoga:height
or yoga:width
. Otherwise they are ignored.
VirtualYogaLayout
Sometimes you will nest YogaLayout
s within YogaLayout
s in order to get your layout to be perfect, but some of the YogaLayout
s are just there to control position: they don't render or anything. If so, then they are unnecessary (since Yoga stores the view hierarchy itself) and VirtualYogaLayout
is a ViewGroup that fixes this. It will never get drawn, but all its children will be placed appropriately.
RTL locales
RTL locales are supported by default. That is, unless you explicitly set the yoga:direction="ltr|rtl|inherit"
attribute on a view, it will obtain the locale direction at runtime. This means that the layout will rearrange properly, even if the locale changes while your app is running!
Attributes
The list of all attributes can be found in attrs.xml, but logically map from the Yoga properties.