From f25164872655adfb19ba11103b43729691b17ebf Mon Sep 17 00:00:00 2001 From: Robert Spencer Date: Tue, 14 Feb 2017 02:39:35 -0800 Subject: [PATCH] Add android docs 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 --- docs/_data/nav_docs.yml | 1 + docs/_docs/api/android.md | 28 ++++++++++++++++++++++++++++ docs/_docs/getting-started.md | 12 +++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 docs/_docs/api/android.md diff --git a/docs/_data/nav_docs.yml b/docs/_data/nav_docs.yml index 63be4d0b..b7e3025a 100644 --- a/docs/_data/nav_docs.yml +++ b/docs/_data/nav_docs.yml @@ -21,5 +21,6 @@ - id: c - id: yogakit - id: java + - id: android - id: csharp - id: javascript diff --git a/docs/_docs/api/android.md b/docs/_docs/api/android.md new file mode 100644 index 00000000..28ab895c --- /dev/null +++ b/docs/_docs/api/android.md @@ -0,0 +1,28 @@ +--- +docid: android +title: Android +layout: docs +permalink: /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](https://github.com/facebook/yoga/blob/master/android/sample/res/com/facebook/samples/yoga/res/values/attrs.xml), but logically map from the Yoga properties. diff --git a/docs/_docs/getting-started.md b/docs/_docs/getting-started.md index 6a8cde69..4b386c00 100644 --- a/docs/_docs/getting-started.md +++ b/docs/_docs/getting-started.md @@ -13,12 +13,22 @@ Installation of Yoga is currently a manual process. We have plans on bringing Yo For now we recommend including Yoga as a [git submodule](https://git-scm.com/docs/git-submodule) in your project. Once done, you can either build Yoga using Buck (detailed [below](#building-with-buck)) or integrate it into your existing build system by including the C library from the [root `yoga` directory](https://github.com/facebook/yoga/tree/master/yoga) as well as the [language bindings](https://github.com/facebook/yoga) (e.g., Java, C#) you wish to use. -### Running the Example +### Running the Examples + +#### iOS Yoga ships with an [iOS example](https://github.com/facebook/yoga/tree/master/YogaKit/YogaKitSample). To get it running: +#### Android + +Yoga ships with an [Android example too](https://github.com/facebook/yoga/tree/master/android/sample). To get it running on an attached device (or emulator): + + + +Actually, this is more than just an example, and more a layout system for Android using Yoga in general (see `YogaLayout`). For more information see the [Android API section](/yoga/docs/api/android). + ### Building with Buck Yoga uses [Buck](https://buckbuild.com/) as its build system. Buck is not required for using Yoga, but, if you already use Buck, then integrating Yoga is very simple.