入門SkinUI(10):佈局(2):彈性佈局

彈性佈局CFlexLayout,繼承於CLayout,支持CLayout的所有屬性和方法。

彈性佈局稱爲 Flex 容器,簡稱"容器"。容器默認存在兩根軸:水平的主軸和垂直的交叉軸。它的的所有子元素稱爲 Flex 項目(flex item),簡稱"項目"。項目默認沿主軸排列。

容器相關的屬性和方法

主軸的方向

  • 通過XML屬性控制如下:
Direction="Row"
Direction="RowReverse"
Direction="Column"
Direction="ColumnReverse"
  • 通過C++程序代碼調用方法控制如下:
virtual void SetDirection(Direction nDirection);

換行方式

  • 通過XML屬性控制如下:
Wrap="NoWrap"
Wrap="Wrap"
Wrap="WrapReverse"
  • 通過C++程序代碼調用方法控制如下:
virtual void SetWrap(Wrap nWrap);

主軸對齊方式

  • 通過XML屬性控制如下:
JustifyContent="Start"
JustifyContent="End"
JustifyContent="Center"
JustifyContent="Between"
JustifyContent="Around"
  • 通過C++程序代碼調用方法控制如下:
virtual void SetJustifyContent(FlexAlign nJustifyContent);

交叉軸對齊方式

  • 通過XML屬性控制如下:
AlignItems="Start"
AlignItems="End"
AlignItems="Center"
AlignItems="Between"
AlignItems="Around"
  • 通過C++程序代碼調用方法控制如下:
virtual void SetAlignItems(FlexAlign nAlignItems);

主軸線對齊方式

  • 通過XML屬性控制如下:
AlignContent="Start"
AlignContent="End"
AlignContent="Center"
AlignContent="Between"
AlignContent="Around"
  • 通過C++程序代碼調用方法控制如下:
virtual void SetAlignContent(FlexAlign nAlignContent);

項目相關的屬性和方法

設置視圖放大係數

  • 通過XML屬性控制如下:
Grow="10"
  • 通過C++程序代碼調用方法控制如下:
virtual void SetGrow(LONG nGrow);

設置視圖縮小系數

  • 通過XML屬性控制如下:
Shrink="10"
  • 通過C++程序代碼調用方法控制如下:
virtual void SetShrink(LONG nShrink);

示例

效果圖

水平方向,起點在左端,不換行

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="NoWrap">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,起點在左端,換行,第一行在上方

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="Wrap">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,起點在左端,換行,第一行在下方

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="WrapReverse">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,起點在右端,不換行

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="RowReverse" Wrap="NoWrap">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,起點在右端,換行,第一行在上方

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="RowReverse" Wrap="Wrap">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,起點在右端,換行,第一行在下方

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="RowReverse" Wrap="WrapReverse">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,起點在上沿,不換行

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="NoWrap">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,起點在上沿,換行,第一行在左邊

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="Wrap">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,起點在上沿,換行,第一行在右邊

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="WrapReverse">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,起點在下沿,不換行

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="ColumnReverse" Wrap="NoWrap">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,起點在下沿,換行,第一行在左邊

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="ColumnReverse" Wrap="Wrap">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,起點在下沿,換行,第一行在右邊

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="ColumnReverse" Wrap="WrapReverse">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,主軸方向左對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="140">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="NoWrap" JustifyContent="Start">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,主軸方向右對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="140">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="NoWrap" JustifyContent="End">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,主軸方向居中對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="140">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="NoWrap" JustifyContent="Center">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,主軸方向兩端對齊,項目之間的間隔都相等

佈局文件

<RelativeLayout Width="MatchParent" Height="140">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="NoWrap" JustifyContent="Between">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,主軸方向每個項目兩側的間隔相等

佈局文件

<RelativeLayout Width="MatchParent" Height="140">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="NoWrap" JustifyContent="Around">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,主軸方向上對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="420">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="NoWrap" JustifyContent="Start">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,主軸方向下對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="420">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="NoWrap" JustifyContent="End">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,主軸方向居中對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="420">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="NoWrap" JustifyContent="Center">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,主軸方向兩端對齊,項目之間的間隔都相等

佈局文件

<RelativeLayout Width="MatchParent" Height="420">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="NoWrap" JustifyContent="Between">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,主軸方向每個項目兩側的間隔相等

佈局文件

<RelativeLayout Width="MatchParent" Height="420">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="NoWrap" JustifyContent="Around">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,交叉軸方向上對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="160">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="NoWrap" AlignItems="Start">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="80" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="60" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,交叉軸方向下對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="160">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="NoWrap" AlignItems="End">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="80" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="60" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,交叉軸方向居中對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="160">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="NoWrap" AlignItems="Center">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="80" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="60" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,交叉軸方向左對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="NoWrap" AlignItems="Start">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="160" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="120" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,交叉軸方向右對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="NoWrap" AlignItems="End">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="160" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="120" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,交叉軸方向居中對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="NoWrap" AlignItems="Center">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="160" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="120" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,軸線上對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="420">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="Wrap" AlignContent="Start">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,軸線下對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="420">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="Wrap" AlignContent="End">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,軸線居中對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="420">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="Wrap" AlignContent="Center">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,軸線兩端對齊,軸線之間的間隔平均分佈

佈局文件

<RelativeLayout Width="MatchParent" Height="420">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="Wrap" AlignContent="Between">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,每根軸線兩側的間隔都相等

佈局文件

<RelativeLayout Width="MatchParent" Height="420">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="Wrap" AlignContent="Around">
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,軸線左對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="Wrap" AlignContent="Start">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,軸線右對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="Wrap" AlignContent="End">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,軸線居中對齊

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="Wrap" AlignContent="Center">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,軸線兩端對齊,軸線之間的間隔平均分佈

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="Wrap" AlignContent="Between">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,每根軸線兩側的間隔都相等

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="Wrap" AlignContent="Around">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='2' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='4' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='5' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='6' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='7' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8">
			<TextView Text='8' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='9' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,項目自動放大

佈局文件

<RelativeLayout Width="MatchParent" Height="140">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="NoWrap">
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT8" Grow="1">
			<TextView Text='我被自動放大了' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="200" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

水平方向,項目自動縮小

佈局文件

<RelativeLayout Width="MatchParent" Height="140">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Row" Wrap="NoWrap">
		<RelativeLayout Width="280" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="280" Height="100" Background="ID_COLOR_DEFAULT8" Shrink="1">
			<TextView Text='我被自動縮小了' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="280" Height="100" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,項目自動放大

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="NoWrap">
		<RelativeLayout Width="240" Height="60" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="60" Background="ID_COLOR_DEFAULT8" Grow="1">
			<TextView Text='我被自動放大了' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="60" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>

效果圖

垂直方向,項目自動縮小

佈局文件

<RelativeLayout Width="MatchParent" Height="340">
	<FlexLayout AlignParentLeft="20" AlignParentTop="20" AlignParentRight="20" AlignParentBottom="20" Background="ID_COLOR_DEFAULT1" Direction="Column" Wrap="NoWrap">
		<RelativeLayout Width="240" Height="120" Background="ID_COLOR_DEFAULT5">
			<TextView Text='1' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="120" Background="ID_COLOR_DEFAULT8" Shrink="1">
			<TextView Text='我被自動縮小了' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
		<RelativeLayout Width="240" Height="120" Background="ID_COLOR_DEFAULT5">
			<TextView Text='3' Width="MatchParent" Height="MatchParent" HorzAlign="Center" Font="ID_FONT_H4" Color="ID_COLOR_WHITE"/>
		</RelativeLayout>
	</FlexLayout>
</RelativeLayout>
發佈了21 篇原創文章 · 獲贊 0 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章