转载自: http://w4lle.com/2016/05/08/Flexbox/
1
|
flex-direction: row | row-reverse | column | column-reverse
|
1
|
flex-wrap: nowrap | wrap | wrap-reverse;
|
1
|
flex-flow: |
1
|
justify-content: flex-start | flex-end | center | space-between | space-around;
|
1
|
align-items: flex-start | flex-end | center | baseline | stretch;
|
1
|
align-content: flex-start | flex-end | center | space-between | space-around | stretch;
|
1
2
3
|
.item {
flex-grow:
}
|
1
2
3
|
.item {
flex-shrink:
}
|
1
2
3
|
.item {
flex-basis:
}
|
1
2
3
|
.item {
flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]
}
|
1
2
3
|
.item {
align-self: auto | flex-start | flex-end | center | baseline | stretch;
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<com.google.android.flexbox.FlexboxLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:flexWrap=
"wrap"
app:alignItems=
"stretch"
app:alignContent=
"stretch" >
<TextView
android:id=
"@+id/textview1"
android:layout_width=
"120dp"
android:layout_height=
"80dp"
app:layout_flexBasisPercent=
"50%"
/>
<TextView
android:id=
"@+id/textview2"
android:layout_width=
"80dp"
android:layout_height=
"80dp"
app:layout_alignSelf=
"center"
/>
<TextView
android:id=
"@+id/textview3"
android:layout_width=
"160dp"
android:layout_height=
"80dp"
app:layout_alignSelf=
"flex_end"
/>
com.google.android.flexbox.FlexboxLayout>
|
1
2
3
4
5
6
7
8
|
FlexboxLayout flexboxLayout = (FlexboxLayout) findViewById(R.id.flexbox_layout);
flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
View view = flexboxLayout.getChildAt(
0);
FlexboxLayout.LayoutParams lp = (FlexboxLayout.LayoutParams) view.getLayoutParams();
lp.order = -
1;
lp.flexGrow =
2;
view.setLayoutParams(lp);
|