首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >网格不适合小米的屏幕

网格不适合小米的屏幕
EN

Stack Overflow用户
提问于 2021-02-02 21:48:55
回答 1查看 44关注 0票数 0

我有一个有点不寻常的问题,在我执行的搜索中没有发现任何引用。

我有一个Xamarin Forms应用程序,在登录屏幕上,Grid不会根据布局进行调整,也不会在屏幕上显示任何控件。

为了更容易理解,我将背景图像替换为纯色图像,从而使屏幕尽可能简单。

我已经多次更改登录屏幕,但都不起作用。我尝试过网格,没有网格,有线的网格,没有线的网格,网格的每一行都有一个Stacklayout,一个Stacklayout,有框架,没有框架,但什么都不能解决。

最糟糕的是,在firebase上进行的测试中,他们没有发现任何错误。

这只在一些小米上发生(在其他设备上,即使是小米,也不会)。

我使用的是VS 2019和Xamarin Forms 4.8.0.1269。

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:MySample.Controls"
BackgroundImage="solid.png"
x:Class="MySample.Views.LoginView">

<ContentPage.Padding>
    <OnPlatform x:TypeArguments="Thickness">
        <On Platform="iOS" Value="0,20,0,0" />
    </OnPlatform>
</ContentPage.Padding>

<ContentPage.Content>

    <Grid x:Name="gridExterno" 
          RowSpacing="0" 
          ColumnSpacing="0" 
          Padding="30,20,30,5" 
          BackgroundColor="White"
          Margin="30,5"  
          VerticalOptions="CenterAndExpand" HorizontalOptions="Center">

        <Grid.MinimumHeightRequest>
            <OnIdiom x:TypeArguments="x:Double" Tablet="600" Phone="300" Desktop="300"/>
        </Grid.MinimumHeightRequest>

        <Grid.MinimumWidthRequest>
            <OnIdiom x:TypeArguments="x:Double" Tablet="800" Phone="600"  Desktop="600"/>
        </Grid.MinimumWidthRequest>

        <Grid.WidthRequest>
            <OnIdiom x:TypeArguments="x:Double" Tablet="800" Phone="600"  Desktop="600"/>
        </Grid.WidthRequest>

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

        <Image Grid.Row="0" Source="logo.png" VerticalOptions="Center" HorizontalOptions="Center" Margin="0,10,0,10">
            <Image.WidthRequest>
                <OnIdiom x:TypeArguments="x:Double" Tablet="350" Phone="300" Desktop="300"/>
            </Image.WidthRequest>
        </Image>

        <StackLayout 
                Orientation="Vertical"
                Grid.Row="1"
                VerticalOptions="Center" 
                HorizontalOptions="Center" 
                Spacing="15" 
                Margin="10">

            <Entry x:Name="EntryLogin" 
                       TextChanged="OnEntryLoginTextChanged"
                       MaxLength="20"
                       Text=""
                       Keyboard="Numeric"  
                       HorizontalOptions="FillAndExpand">

                <Entry.WidthRequest>
                    <OnIdiom x:TypeArguments="x:Double" Tablet="400" Phone="300" Desktop="300"/>
                </Entry.WidthRequest>

                <Entry.HeightRequest>
                    <OnIdiom x:TypeArguments="x:Double" Tablet="75" Phone="50" Desktop="50"/>
                </Entry.HeightRequest>

                <Entry.Margin>
                    <OnIdiom x:TypeArguments="Thickness" Tablet="0,0,0,20" Phone="0" Desktop="0"/>
                </Entry.Margin>

                <Entry.FontSize>
                    <OnIdiom x:TypeArguments="x:Double" Tablet="30" Phone="20" Desktop="20" />
                </Entry.FontSize>
            </Entry>

            <Entry x:Name="EntryPassword" 
                        Text=""
                        MaxLength="20"
                        IsPassword="True" 
                        HorizontalOptions="FillAndExpand">

                <Entry.Margin>
                    <OnIdiom x:TypeArguments="Thickness" Tablet="0,0,0,20" Phone="0" Desktop="0"/>
                </Entry.Margin>

                <Entry.WidthRequest>
                    <OnIdiom x:TypeArguments="x:Double" Tablet="400" Phone="300" Desktop="300"/>
                </Entry.WidthRequest>

                <Entry.HeightRequest>
                    <OnIdiom x:TypeArguments="x:Double" Tablet="75" Phone="50" Desktop="50"/>
                </Entry.HeightRequest>

                <Entry.FontSize>
                    <OnIdiom x:TypeArguments="x:Double" Tablet="28" Phone="20" Desktop="20"/>
                </Entry.FontSize>
            </Entry>

            <StackLayout Orientation="Horizontal" Spacing="16" HorizontalOptions="FillAndExpand">
                <StackLayout.Margin>
                    <OnIdiom x:TypeArguments="Thickness" Tablet="2,0" Phone="0"  Desktop="0"/>
                </StackLayout.Margin>

                <CheckBox x:Name="ckRemember"/>

                <Label Text="Remember Me" VerticalOptions="Center">
                    <Label.FontSize>
                        <OnIdiom x:TypeArguments="x:Double" Tablet="26" Phone="18"  Desktop="18"/>
                    </Label.FontSize>
                </Label>
            </StackLayout>

            <Button  x:Name="btnEntrar1" 
                                Text="Enter" 
                                BackgroundColor="{StaticResource ButtonPrimary}" 
                                Clicked="OnLoginAsync"
                                TextColor="White" 
                                HorizontalOptions="FillAndExpand">

                <Button.WidthRequest>
                    <OnIdiom x:TypeArguments="x:Double" Tablet="400" Phone="300" Desktop="300"/>
                </Button.WidthRequest>

                <Button.HeightRequest>
                    <OnIdiom x:TypeArguments="x:Double" Tablet="75" Phone="50" Desktop="50"/>
                </Button.HeightRequest>

                <Button.FontSize>
                    <OnIdiom x:TypeArguments="x:Double" Tablet="18" />
                </Button.FontSize>

                <Button.Margin>
                    <OnIdiom x:TypeArguments="Thickness" Tablet="0,15,0,0" Phone="0"  Desktop="0"/>
                </Button.Margin>
            </Button>

            <Label x:Name="lblVersion" 
                VerticalOptions="End" 
                HorizontalTextAlignment="Center" 
                HorizontalOptions="Center">

                <Label.FontSize>
                    <OnIdiom x:TypeArguments="x:Double" Tablet="20" Phone="16" Desktop="16"/>
                </Label.FontSize>

                <Label.Margin>
                    <OnIdiom x:TypeArguments="Thickness" Tablet="0,0,0,10" Phone="0,3,0,5"  Desktop="0,3,0,5"/>
                </Label.Margin>
            </Label>
        </StackLayout>
    </Grid>
</ContentPage.Content>
</ContentPage>
EN

回答 1

Stack Overflow用户

发布于 2021-02-03 00:32:13

x:Name="gridExterno" HorizontalOptions更改为HorizontalOptions="CenterAndExpand"

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66011042

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档