Skip to content

Commit 99a4b66

Browse files
authored
Bump the version to 0.3.0. (#324)
For a stable release including RecyclerView integration: - Bump the library version. - Update the README
1 parent f51d920 commit 99a4b66

File tree

3 files changed

+70
-101
lines changed

3 files changed

+70
-101
lines changed

README.md

Lines changed: 69 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,23 @@
55
FlexboxLayout is a library project which brings the similar capabilities of
66
[CSS Flexible Box Layout Module](https://www.w3.org/TR/css-flexbox-1) to Android.
77

8-
## Installation
8+
# Installation
99
Add the following dependency to your `build.gradle` file:
1010

11-
Stable
1211
```
1312
dependencies {
14-
compile 'com.google.android:flexbox:0.2.7'
13+
compile 'com.google.android:flexbox:0.3.0'
1514
}
1615
```
1716

18-
OR
19-
20-
Alpha including RecyclerView integration
21-
```
22-
dependencies {
23-
compile 'com.google.android:flexbox:0.3.0-alpha4'
24-
}
25-
```
2617
See the [RecyclerView integration](RecyclerView.md) page for more details about using Flexbox inside
2718
the `RecyclerView`.
2819

29-
## Usage
30-
FlexboxLayout extends the ViewGroup like LinearLayout and RelativeLayout.
20+
# Usage
21+
There are two ways of using Flexbox in your layout.
22+
23+
## FlexboxLayout
24+
The first one is `FlexboxLayout` that extends the `ViewGroup` like `LinearLayout` and `RelativeLayout`.
3125
You can specify the attributes from a layout XML like:
3226
```xml
3327
<com.google.android.flexbox.FlexboxLayout
@@ -65,7 +59,7 @@ You can specify the attributes from a layout XML like:
6559
Or from code like:
6660
```java
6761
FlexboxLayout flexboxLayout = (FlexboxLayout) findViewById(R.id.flexbox_layout);
68-
flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
62+
flexboxLayout.setFlexDirection(FlexDirection.ROW);
6963

7064
View view = flexboxLayout.getChildAt(0);
7165
FlexboxLayout.LayoutParams lp = (FlexboxLayout.LayoutParams) view.getLayoutParams();
@@ -74,9 +68,62 @@ lp.flexGrow = 2;
7468
view.setLayoutParams(lp);
7569
```
7670

77-
## Supported attributes
71+
## FlexboxLayoutManager (within RecyclerView)
72+
The second one is `FlexboxLayoutManager` that can be used within `RecyclerView`.
73+
74+
```java
75+
RecyclerView recyclerView = (RecyclerView) context.findViewById(R.id.recyclerview);
76+
FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(context);
77+
layoutManager.setFlexDirection(FlexDirection.COLUMN);
78+
layoutManager.setJustifyContent(JustifyContent.FLEX_END);
79+
recyclerView.setLayoutManager(layoutManager);
80+
```
81+
82+
or for the attributes for the children of the `FlexboxLayoutManager` you can do like:
83+
84+
```java
85+
mImageView.setImageDrawable(drawable);
86+
ViewGroup.LayoutParams lp = mImageView.getLayoutParams();
87+
if (lp instanceof FlexboxLayoutManager.LayoutParams) {
88+
FlexboxLayoutManager.LayoutParams flexboxLp = (FlexboxLayoutManager.LayoutParams) lp;
89+
flexboxLp.setFlexGrow(1.0f);
90+
flexboxLp.setAlignSelf(AlignSelf.FLEX_END);
91+
}
92+
```
7893

79-
#### Attributes for the FlexboxLayout:
94+
The advantage of using `FlexboxLayoutManager` is that it recycles the views that go off the screen
95+
for reuse for the views that are appearing as the user scrolls instead of inflating every individual view.
96+
97+
## Supported attributes / features comparison
98+
Due to some characteristics of `RecyclerView`, some Flexbox attributes are not available/not implemented
99+
to the `FlexboxLayoutManager`.
100+
Here is a quick overview of the attributes/features comparison between the two implementations.
101+
102+
|Attribute / Feature|FlexboxLayout| FlexboxLayoutManager (RecyclerView)|
103+
| ------- |:-----------:|:----------------------------------:|
104+
|flexDirection|![Check](/assets/pngs/check_green_small.png)|![Check](/assets/pngs/check_green_small.png)|
105+
|flexWrap|![Check](/assets/pngs/check_green_small.png)|![Check](/assets/pngs/check_green_small.png) (except `wrap_reverse`)|
106+
|justifyContent|![Check](/assets/pngs/check_green_small.png)|![Check](/assets/pngs/check_green_small.png)|
107+
|alignItems|![Check](/assets/pngs/check_green_small.png)|![Check](/assets/pngs/check_green_small.png)|
108+
|alignContent|![Check](/assets/pngs/check_green_small.png)| - |
109+
|layout_order|![Check](/assets/pngs/check_green_small.png)| - |
110+
|layout_flexGrow|![Check](/assets/pngs/check_green_small.png)|![Check](/assets/pngs/check_green_small.png)|
111+
|layout_flexShrink|![Check](/assets/pngs/check_green_small.png)|![Check](/assets/pngs/check_green_small.png)|
112+
|layout_alignSelf|![Check](/assets/pngs/check_green_small.png)|![Check](/assets/pngs/check_green_small.png)|
113+
|layout_flexBasisPercent|![Check](/assets/pngs/check_green_small.png)|![Check](/assets/pngs/check_green_small.png)|
114+
|layout_(min/max)Width|![Check](/assets/pngs/check_green_small.png)|![Check](/assets/pngs/check_green_small.png)|
115+
|layout_(min/max)Height|![Check](/assets/pngs/check_green_small.png)|![Check](/assets/pngs/check_green_small.png)|
116+
|layout_wrapBefore|![Check](/assets/pngs/check_green_small.png)|![Check](/assets/pngs/check_green_small.png)|
117+
|Divider|![Check](/assets/pngs/check_green_small.png)|![Check](/assets/pngs/check_green_small.png)|
118+
|View recycling| - |![Check](/assets/pngs/check_green_small.png)|
119+
|Scrolling| *1 |![Check](/assets/pngs/check_green_small.png)|
120+
121+
*1 Partially possible by wrapping it with `ScrollView`. But it isn't likely to work with large set
122+
of views inside the layout. Because it doesn't consider view recycling.
123+
124+
# Supported attributes
125+
126+
## Attributes for the FlexboxLayout:
80127

81128
* __flexDirection__
82129
* This attribute determines the direction of the main axis (and the cross axis, perpendicular to the main axis). The direction children items are placed inside the Flexbox layout.
@@ -200,7 +247,7 @@ view.setLayoutParams(lp);
200247
![Dividers beginning and middle](/assets/divider-beginning-middle.png)
201248

202249

203-
#### Attributes for the children of a FlexboxLayout
250+
## Attributes for the children of a FlexboxLayout
204251

205252
* __layout_order__ (integer)
206253
* This attribute can change how the ordering of the children views are laid out.
@@ -281,6 +328,8 @@ view.setLayoutParams(lp);
281328

282329
![Wrap before explanation](/assets/layout_wrapBefore.gif)
283330

331+
# Others
332+
284333
## Known differences from the original CSS specification
285334
This library tries to achieve the same capabilities of the original
286335
[Flexible Box specification](https://www.w3.org/TR/css-flexbox-1) as much as possible,
@@ -317,15 +366,15 @@ equivalent attribute
317366
## Xamarin Binding
318367
Xamarin binding is now available on [NuGet](https://www.nuget.org/packages/FlexboxLayoutXamarinBindingAndroid/) thanks to [@btripp](https://github.com/btripp)
319368

320-
321-
## Flexbox Playground demo app
369+
## Demo apps
370+
### Flexbox Playground demo app
322371
The `app` module works as a playground demo app for trying various values for the supported attributes.
323372
You can install it by
324373
```
325374
./gradlew demo-playground:installDebug
326375
```
327376

328-
## Cat gallery demo app
377+
### Cat gallery demo app
329378
The `demo-cat-gallery` module showcases the usage of the FlexboxLayoutManager inside the RecyclerView
330379
that handles various sizes of views aligned nicely regardless of the device width like the
331380
Google Photo app without loading all the images on the memory.

RecyclerView.md

Lines changed: 0 additions & 80 deletions
This file was deleted.

flexbox/constants.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ext {
2222

2323
mavenGroup = 'com.google.android'
2424
mavenArtifactId = 'flexbox'
25-
mavenVersion = '0.3.0-alpha4'
25+
mavenVersion = '0.3.0'
2626

2727
bintrayOrg = 'google'
2828
}

0 commit comments

Comments
 (0)