【问题标题】:Frame overrides Label TextColor only on Android (xamarin-forms)框架仅在 Android 上覆盖 Label TextColor (xamarin-forms)
【发布时间】:2019-01-14 14:11:58
【问题描述】:

我编写了以下 xaml,但我在 android 上遇到了问题。 Frame 控件覆盖了 Label 中的颜色,我不知道为什么。当我用完美的网格替换框架时,但我想要拐角半径的框架。

这是一个错误?可以修吗?

             <Grid x:Name="Frame_6_10">
                <Frame WidthRequest="30" BackgroundColor="#55b040" IsClippedToBounds="true" CornerRadius="10"/>
                <Label Margin="0,7,0,0" Text="6-10" TextColor="White" FontSize="16" HorizontalOptions="Center" 
                       VerticalOptions="Center" HorizontalTextAlignment="Center" FontAttributes="Bold"/>
                <ContentView HeightRequest="7" VerticalOptions="Start" WidthRequest="30" BackgroundColor="#55b040"/>
             </Grid>

我使用 Xamarin Forms 版本 3.1.0.697729

【问题讨论】:

  • 我这里有几个问题,比如为什么你的框架里面什么都没有?和一个标签外面呢?然后是内容视图,你想在这里做什么
  • 我只希望底角有半径。我在开始时使用内容视图来隐藏顶部框架角。
  • 您知道您应该将图像用于此类事情,对吧?你不要用代码做这样的布局!
  • 图像对于此范围的不同分辨率不是很好的做法。
  • 我的问题是为什么所有其他元素的颜色都覆盖了框架的前面。

标签: android xaml xamarin xamarin.forms xamarin.android


【解决方案1】:

从您的代码来看,我认为它是覆盖标签的内容视图。尝试删除它,看看会发生什么。

【讨论】:

  • ContentView 的位置非常好。这不是问题。谢谢
  • 我很抱歉,我看你是对的,正如你所解释的,这个问题只适用于安卓。你不能用 boxview 代替 frame 吗?或在框架内放置网格
【解决方案2】:

把你的 Frame 和 contentView 放在里面

    <Grid x:Name="Frame_6_10">
         <Frame WidthRequest="30" BackgroundColor="#55b040" IsClippedToBounds="true" 
          CornerRadius="10">
              <ContentView HeightRequest="7" VerticalOptions="Start" 
               WidthRequest="30" BackgroundColor="#55b040">
                    <Label Margin="0,7,0,0" Text="6-10" TextColor="White" 
                       FontSize="16" HorizontalOptions="Center" 
                       VerticalOptions="Center" HorizontalTextAlignment="Center" 
                       FontAttributes="Bold"/>
               </ContentView>
      </Frame>         
</Grid>

【讨论】:

    猜你喜欢
    • 2020-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-08
    • 2019-04-16
    • 2019-01-17
    • 2019-05-02
    • 2013-12-23
    相关资源
    最近更新 更多