首页 > 解决方案 > Xamarin Forms如何水平填充图像视图并垂直扩展?

问题描述

我在固定ImageButton的宽度时遇到问题,并且高度将随着我在 ImageButton 中使用的图像大小而改变,我在Scrollview中多次使用ImageButton,我使用Visual Studio创建一个跨平台使用Xamarin的应用程序,所以我用来解决我的问题的方法在这里这里,但我无法使用任何东西来解决它,这是一张描述我想要的图片:- 在此处输入图像描述

如果我的问题有答案,请不要重复,因为我是Xamarin Forms的新手,而且我没有找到任何完全符合我的问题的答案,这是我的代码:-

<Frame CornerRadius="10"  OutlineColor="#fce9cc" Padding="4" Margin="15" VerticalOptions="StartAndExpand" 
       HasShadow="True" x:Name="ViewLayout" x:FieldModifier="public" BackgroundColor="Black">
        <StackLayout>
            <Label x:Name="filmNameLabel_1"  HorizontalOptions="Center" FontSize="Large" TextColor="White"
                   Margin="0,15,0,15"/>

            <StackLayout Orientation="Vertical">
                <ImageButton x:Name="imageWidget_1" BackgroundColor="Black" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Aspect="AspectFill"/>
            </StackLayout>

        </StackLayout>
    </Frame>

第一次我将StackLayoutImageButton的 HeightRequest 的父级设置为一个数字,它会使ImageButton高度成为一个固定数字,但我不希望ImageButton高度随着图像的大小而改变再见固定在父布局旁边的宽度。

标签: imagexamarinlayoutxamarin.formscross-platform

解决方案


推荐阅读