我正试图在我的Xamarin表单应用程序中创建一个定制的、材料风格的、卡片单元格。我的外表很差,但我的形象有问题。我想要它接触顶部和底部边缘,左手边,并成为一个方形的形状,同时保持高宽比。但现在,我得到的只是这张不能打球的小图像:

(我不得不用油漆覆盖公司的图像,但相信我,它们的尺寸差不多)。
这是我真正想要的(再次,请原谅我的油漆工作)

我在网格视图中使用一个图像,在第一列中,并跨越所有4行。我试过所有的LayoutOptions,我曾经理解过,但现在我开始怀疑自己了。我还尝试将图像放入Stacklayout中,因为我认为您可以扩展StackLayout的子级,但仍然没有骰子。下面是我现在简化的Xaml:
<Frame CornerRadius="10"
Margin="10, 5"
IsClippedToBounds="True"
BackgroundColor="White">
<Grid BackgroundColor="White" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackLayout Grid.Row="0" Grid.Column="0" Grid.RowSpan="4"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Image HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Aspect="AspectFill" Source="{Binding ImageSource}"/>
</StackLayout>
<Label Grid.Row="0" Grid.Column="1"
Text="{Binding Favourite.FavKindName}"
FontSize="{DynamicResource InfoLargerTextFontSize}"/>
<Image Grid.Row="1" Grid.Column="3" Grid.RowSpan="4" Source="Contact.png"
VerticalOptions="CenterAndExpand" >
<Image.GestureRecognizers>
<TapGestureRecognizer />
</Image.GestureRecognizers>
</Image>
</Grid>
</Frame>更重要的是,你可能知道我对右边的电话图标一无所知。我希望它能占据中心位置,并使卡片单元的按键尺寸更大。
我花了好几个小时想办法解决这个问题。我做错了什么?
发布于 2018-07-03 18:02:20
Frame的默认Padding为20,这就是为什么在框架中有这些边距的原因。
<Frame Padding="0" // Here , set padding to 0, so you can fill all Frame space
CornerRadius="10"
Margin="10, 5"
IsClippedToBounds="True"
BackgroundColor="White">https://stackoverflow.com/questions/51159545
复制相似问题