我正在尝试显示一个包含某些项目的列表视图,我只想在这些项目之间留出一些空间。
我用谷歌搜索,但是找不到适合我的答案。这是我发现的解决方案,其结果与我想要的相同,但没有起作用:https : //stackoverflow.com/a/30827419/1845593
我正在使用xamarin表格2.3.2.127,为此我想保留xaml。
我的xaml代码:
<pages:MainXaml.Content>
<ListView x:Name="AccountsList"
ItemsSource="{Binding Items}"
SeparatorVisibility="None"
BackgroundColor="Gray">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout BackgroundColor="White" Margin="0,0,0,20" >
<Label Text="{Binding Name}"
VerticalTextAlignment="Center"
LineBreakMode="TailTruncation"
/>
<Label Text="{Binding Amount}"
VerticalTextAlignment="Center"
LineBreakMode="TailTruncation"/>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</pages:MainXaml.Content>
Run Code Online (Sandbox Code Playgroud)
我尝试了间距,填充和边界,但没有一个起作用。
视觉结果/预期:
谢谢
我试图做一个基于卡的ListView在基于断ahaliav狐狸的XAML例子Xamarin形式在这里不过我没有得到什么附近他得到的任何地方我只有一个文本标签,我需要在卡中显示
继承我的xaml代码:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="WebSearch.CountySelect" BackgroundColor="Gray">
<ListView x:Name="listView">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Frame Padding="0,0,0,3">
<Frame.Content>
<Frame Padding="15,15,15,15" OutlineColor="Gray" BackgroundColor="White">
<Frame.Content>
<StackLayout Padding="20,0,0,0" Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
<Label Text="{Binding Name}"
FontFamily="OpenSans-Light"
FontSize="9"
TextColor="#69add1"/>
</StackLayout>
</Frame.Content>
</Frame>
</Frame.Content>
</Frame>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)
编辑:我通过使用框架得到ListView项目类似于卡但标签上的文字切断了一半,除非我使文本大小9或更低,以任何方式解决这个错误?
我更新了我的代码以反映我遇到的新问题
任何帮助都会很棒!