【问题标题】:Xamarin Forms transparent element with borderXamarin Forms 带边框的透明元素
【发布时间】:2016-12-12 21:40:10
【问题描述】:

我正在使用Frame 在各种元素(Grid、StackLayout 和 ContentView)上创建边框,现在需要使元素透明;我尝试设置网格等的不透明度,但Frame 颜色当然会影响实际的背景颜色。

<ContentPage BackgroundImage="some_image.png">
  <!-- ... -->
  <Frame BackgroundColor="Gray" Opacity="0.7" Padding="1" Margin="10">
    <Grid BackgroundColor="White" Opacity="0.7" Margin="20">
      <Label Text="..."/>
    </Grid>
  </Frame>
  <!-- ... -->
</ContentPage>

Grid 按预期呈现,但现在框架灰色背景使白色网格显示为灰色。理想情况下,我想要一个带有实心灰色边框的白色透明网格,这在 Xamarin 中可行吗?

(我正在使用面向 iOS 和 Android 的共享 Xamarin 表单项目)

【问题讨论】:

  • 对于像我这样想要 xaml 意大利面的懒惰键盘战士

标签: xaml xamarin xamarin.forms


【解决方案1】:

您可以将BackgroundColor 设置为“透明”,将OutlineColor 设置为“灰色”:

<ContentPage BackgroundImage="some_image.png">
  <!-- ... -->
  <Frame BackgroundColor="Transparent" OutlineColor="Gray" Opacity="0.7" Padding="1" Margin="10">
    <Grid BackgroundColor="White" Opacity="0.7" Margin="20">
      <Label Text="..."/>
    </Grid>
  </Frame>
  <!-- ... -->
</ContentPage>

【讨论】:

  • 很好的解决方案,我不知道OutlineColor 属性。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-11-13
  • 1970-01-01
  • 2013-01-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多