制作Xamarin形式的响应框架

问题描述 投票:0回答:1

我试图用Xamarin形式压抑。但是没有运气。他是我的尝试。

<StackLayout Spacing="0" Padding="20">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="10"/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>

        <Label x:Name="pol1" Text="some text" FontSize="Title" Grid.Row="1"/>
        <Frame BackgroundColor="Gray" Grid.Row="2" HasShadow="True" CornerRadius="10">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="20"/>
                    <RowDefinition Height="20"/>
                    <RowDefinition Height="200"/>
                    <RowDefinition Height="20"/>
                    <RowDefinition Height="5"/>
                    <RowDefinition Height="5"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <StackLayout Spacing="0">
                    <Label Text="some text" Grid.Row="2"/>
                    <Label Text="some text" Grid.Row="3"/>
                    <Label Text="some text" Grid.Row="4"/>
                    <Label Text="some text some textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome text" Grid.Row="5"/>
                    <Label Text="some textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome text" Grid.Row="6"/>
                    <Label Text="some textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome text" Grid.Row="6"/>
                </StackLayout>
            </Grid>
        </Frame>
    </Grid>
</StackLayout> 

enter image description here

但是框架不能缩放到文本。我想使其缩放到文本的末尾。

xaml xamarin.forms
1个回答
0
投票
这里的StackLayout用法和索引是问题。在这种情况下,父级布局将无法正确测量尺寸。我已经删除了不需要的StackLayouts以使其得到优化。现在可以使用以下代码获得所需的结果。
© www.soinside.com 2019 - 2024. All rights reserved.