【问题标题】:Xamarin Forms Label inside Frame not showing框架内的 Xamarin 表单标签未显示
【发布时间】:2019-12-25 00:36:57
【问题描述】:

我有问题。我使用以下代码在我的页面中创建了一个框架:

<Grid BackgroundColor="#212121">

    <Grid.RowDefinitions>
        <RowDefinition Height="50" />
        <RowDefinition Height="*" />
        <RowDefinition Height="50" />
    </Grid.RowDefinitions>


    <Grid Grid.Row="1" Margin="20, 0, 20, 0">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="50" />
            <RowDefinition Height="50" />
            <RowDefinition Height="50" />
            <RowDefinition Height="30" />
            <RowDefinition Height="50" />
            <RowDefinition Height="40" />
            <RowDefinition Height="40" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Image Source="Logo.png" HeightRequest="200" VerticalOptions="End" Margin="30" />
        <Entry Grid.Row="1" Placeholder="Username" PlaceholderColor="#bababa" FontSize="16" x:Name="txtUsername" TextColor="White" />
        <Entry Grid.Row="2" Placeholder="Email" PlaceholderColor="#bababa" FontSize="16" x:Name="txtEmail" TextColor="White" />
        <Entry Grid.Row="3" Placeholder="Password" PlaceholderColor="#bababa" FontSize="16" IsPassword="True" x:Name="txtPassword" TextColor="White" TextChanged="OnPasswordTextChanged" />

        <Frame Grid.Row="4" BackgroundColor="Transparent" BorderColor="Transparent" x:Name="FramePasswordStrength" >
            <Label Text="Test" BackgroundColor="Purple" TextColor="White" HorizontalOptions="Center" VerticalOptions="Center" x:Name="txtPasswordStrength" FontSize="14" />
        </Frame>

        <Entry Grid.Row="5" Placeholder="Confirm Password" PlaceholderColor="#bababa" FontSize="16" IsPassword="True" x:Name="txtConfirmPassword" TextColor="White" />
        <Button Text="Sign up" FontAttributes="Bold" Clicked="btnRegisterClicked" BackgroundColor="#3897F0" TextColor="White" HeightRequest="50" VerticalOptions="Start" Grid.Row="6" />
    </Grid>
</Grid>

问题是我的框架按我想要的方式绘制,但该框架的中心没有标签。现在我已经尝试过减小 FontSize,但这不起作用。

我做错了什么?

【问题讨论】:

  • 它对我来说很好用。您是否尝试过任何正常的故障排除步骤 - 重新启动、重新启动 VS、清理/重建您的解决方案等?
  • 另外,您是否尝试过明确设置标签的背景颜色?
  • 是的,刚刚尝试了所有建议的选项。等一下,我会给你完整的代码!
  • 我将完整代码添加到问题中

标签: xamarin xamarin.forms xamarin.android xamarin.ios


【解决方案1】:

尝试将&lt;RowDefinition Height="Auto" /&gt; 设置为行的高度,以便所有控件的高度都正确。

您还可以将Frame的VerticalLayoutHorizontalLayout设置为FillAndExpand

【讨论】:

    【解决方案2】:

    实际问题是 Frame 的默认填充为 20 以将其子元素显示为框架效果。要解决您的问题,请调整填充。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-23
      • 1970-01-01
      • 1970-01-01
      • 2021-12-07
      • 1970-01-01
      • 2014-05-31
      • 1970-01-01
      • 2018-10-17
      相关资源
      最近更新 更多