xamarin - 使用 FlexLayout 换行,如何在行之间留出空间?
问题描述
我正在使用 FlexLayout 来尝试使按钮环绕。它可以工作,但按钮行之间没有空格。
有谁知道我如何确保两者之间有空间。这是我正在使用的 XAML,下面是它的样子:
<StackLayout Orientation="Vertical"
BackgroundColor="{DynamicResource GridBackgroundColor}"
Spacing="0"
Padding="20" >
<FlexLayout x:Name="flexLayout"
Wrap="Wrap"
JustifyContent="SpaceAround" >
<Button BackgroundColor="Silver" Padding="10" Margin="5" Text="Introduction" />
<Button BackgroundColor="Silver" Padding="10" Margin="5" Text="Learning" />
<Button BackgroundColor="Silver" Padding="10" Margin="5" Text="Home" />
<Button BackgroundColor="Silver" Padding="10" Margin="5" Text="Help" />
<Button BackgroundColor="Silver" Padding="10" Margin="5" Text="Settings" />
<Button BackgroundColor="Silver" Padding="10" Margin="5" Text="Dictionary" />
<Button BackgroundColor="Silver" Padding="10" Margin="5" Text="Cards" />
</FlexLayout>
</StackLayout>
解决方案
解决方案:
尝试添加HeightRequest
和/或WidthRequest
您的button
.
<ContentPage.Resources>
<Style TargetType="Button">
<Setter Property="HeightRequest" Value="40"></Setter>
<Setter Property="Margin" Value="5"></Setter>
</Style>
</ContentPage.Resources>
<StackLayout Orientation="Vertical"
BackgroundColor="{DynamicResource GridBackgroundColor}"
Spacing="0"
Padding="20">
<FlexLayout
Wrap="Wrap"
JustifyContent="SpaceAround"
Direction="Row">
<Button BackgroundColor="Silver" Text="Introduction" />
<Button BackgroundColor="Silver" Text="Learning" />
<Button BackgroundColor="Silver" Text="Home" />
<Button BackgroundColor="Silver" Text="Help" />
<Button BackgroundColor="Silver" Text="Settings" />
<Button BackgroundColor="Silver" Text="Dictionary" />
<Button BackgroundColor="Silver" Text="Cards" />
</FlexLayout>
</StackLayout>
推荐阅读
- r - data.table 没有按预期修改列
- php - 用于过滤包含多维数组中搜索的值的 eval
- .net - If条件VB.net中的Linq Where语句
- julia - Julia - 定义一个二维数组,其中一个数组作为一维元素
- docker - docker-compose 日志记录不适用于 syslog 选项
- delphi - 如何将所有 *.txt 打开到列表框
- python - Python 函数中的 reStructuredText 未在 Robot Framework hub 中显示
- r - Forecast::ets, auto.arima 偏移 1
- python - 如何防止 python 服务器写入终端窗口?
- ios - 向 tableViewCell 添加一些标签。表数取决于服务器数据