Xamarin 的 GridLayout 问题

问题描述 投票:0回答:1
 <Grid
                                Margin="30,30,30,30"
                                BackgroundColor="{StaticResource ColorBack002}"
                                RowSpacing="40">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="3*" />
                                    <ColumnDefinition Width="7*" />
                                </Grid.ColumnDefinitions>


                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>



                                <!--#region Method Name-->
                                <Label x:Name="xTxtMethod"
                                    Grid.Row="0"
                                    Grid.Column="0"
                                    Style="{StaticResource LabelStyle}"
                                    Text="Name" />


                                <Ctrl:CtrlTextEdit x:Name="xEditMethodname"
                                    Grid.Row="0"
                                    Grid.Column="1"
                                    BoxHeight="70"
                                    Margin="0,0,15,0"
                                    HorizontalOptions="FillAndExpand"
                                    Style="{StaticResource TextEditStyle}"
                                    Text="{Binding MethodName}" />
                                <!--#endregion-->

我有这样的布局。我将 TextEdit 的 HorizontalOption 设置为 FillAndExpand。 在屏幕上,TextEdit 的提示被切断了大约 1 个像素。为什么会这样?

Textedit 似乎被扩展以适应屏幕,但它似乎已经扩展到更远的地方。

enter image description here

xamarin xamarin.forms xamarin.android
1个回答
0
投票
                <Ctrl:CtrlScrollView x:Name="xScroll" BackgroundColor="{StaticResource ColorBack002}">

                    <Grid
                        Margin="30,30,30,30"
                        BackgroundColor="{StaticResource ColorBack002}"
                        HorizontalOptions="FillAndExpand"
                        RowSpacing="40"
                        VerticalOptions="FillAndExpand">

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="3*" />
                            <ColumnDefinition Width="7*" />
                        </Grid.ColumnDefinitions>


                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>




                        <!--#region Method Name-->
                        <Label x:Name="xTxtMethod"
                            Grid.Row="0"
                            Grid.Column="0"
                            Style="{StaticResource LabelStyle}"
                            Text="Name" />

                        <Ctrl:CtrlTextEdit x:Name="xEditMethodname"
                            Grid.Row="0"
                            Grid.Column="1"
                            Margin="0,0,1,0"
                            BoxHeight="70"
                            HorizontalOptions="FillAndExpand"
                            Style="{StaticResource TextEditStyle}"
                            Text="{Binding MethodName}" />
                        <!--#endregion-->




                        <!--#region Cell Type-->
                        <Label
                            Grid.Row="1"
                            Grid.Column="0"
                            Style="{StaticResource LabelStyle}"
                            Text="Cell Type">
                            <Label.GestureRecognizers>
                                <TapGestureRecognizer Command="{Binding CellTypeClick}" />
                            </Label.GestureRecognizers>
                        </Label>

                        <Ctrl:CtrlTextBox x:Name="xEditCellType"
                            Grid.Row="1"
                            Grid.Column="1"
                            Margin="0,0,1,0"
                            HeightRequest="70"
                            HorizontalOptions="FillAndExpand"
                            TextPadding="10,0,0,0">
                            <Ctrl:CtrlTextBox.GestureRecognizers>
                                <TapGestureRecognizer Tapped="BtnCellTypeClick" />
                            </Ctrl:CtrlTextBox.GestureRecognizers>
                        </Ctrl:CtrlTextBox>
                        <!--#endregion-->

我给了 1 的保证金值,让它现在可见。

© www.soinside.com 2019 - 2024. All rights reserved.