【问题标题】:How to give a shadow effect to a frame in xamarin forms如何在 xamarin 表单中为框架提供阴影效果
【发布时间】:2018-06-23 16:18:08
【问题描述】:

我是 xamarin 的新手,我想为我的框架添加阴影效果并避免框架的顶部边框线,我尝试了框架的“hasShadow”属性,但这对我没有帮助。我该怎么做。

请帮帮我

这是我的 Xaml

 <ListView x:Name="lv_search" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" RowHeight="105" ItemTapped="lv_search_ItemTapped"
                          SeparatorColor="White" BackgroundColor="Black" Margin="0,15,0,0">
                    <ListView.ItemTemplate>
                      <DataTemplate>
                        <ViewCell>
                          <Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="White">
                            <Grid Margin="20,10,0,10" BackgroundColor="White">
                              <Frame  BackgroundColor="White" >
                                <StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
                                  <StackLayout Orientation="Horizontal" HorizontalOptions="StartAndExpand" VerticalOptions="FillAndExpand" Margin="0,0,10,0">
                                    <AbsoluteLayout  HorizontalOptions="StartAndExpand">
                                      <Image Source="ellipse_1" VerticalOptions="CenterAndExpand" HorizontalOptions="FillAndExpand"
                                         AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0.01,0.4,1,1" BackgroundColor="White"/>
                                         <Image Source="{Binding Image}" AbsoluteLayout.LayoutBounds="0.02,0.4,1,1" AbsoluteLayout.LayoutFlags="All"
                                           HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"  />
                                    </AbsoluteLayout>

                                    <StackLayout AbsoluteLayout.LayoutBounds="0.035,0.5,1,1" AbsoluteLayout.LayoutFlags="All" Orientation="Horizontal"
                                      HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand">
                                      <Label x:Name="lbl_categories" HorizontalOptions="StartAndExpand" VerticalOptions="CenterAndExpand" 
                                        Margin="10,0,0,0" FontFamily="Proxima-Nova-Semibold"  TextColor="#222222"  Text="{Binding Title}" 
                                        LineBreakMode="WordWrap"  HorizontalTextAlignment="Start" FontSize="17.3" FontAttributes="Bold"/>
                                    </StackLayout>
                                    </StackLayout>
                                     <Image HorizontalOptions="EndAndExpand" VerticalOptions="Center" Source="arrow"  
                                       AbsoluteLayout.LayoutBounds="0.9,0.3,0,0.3" AbsoluteLayout.LayoutFlags="All" />
                                 </StackLayout>
                               </Frame>
                          </Grid>
                           <Image Source="img_frm" Margin="15,0,0,0" AbsoluteLayout.LayoutBounds="1,0.5,1,1" HorizontalOptions="StartAndExpand"
                            AbsoluteLayout.LayoutFlags="All"/>
                       </Grid>
                    </ViewCell>
                  </DataTemplate>
                </ListView.ItemTemplate>
             </ListView>

代码给出了这个输出

但我想要这样的页面

页面差异用蓝色墨水标记。

【问题讨论】:

    标签: c# xamarin.forms frame shadow


    【解决方案1】:

    Alex Dunn 的这篇文章看起来正是您想要的: https://alexdunn.org/2018/06/06/xamarin-tip-dynamic-elevation-frames/

    请注意,您可以根据需要控制海拔高度

    【讨论】:

      【解决方案2】:

      您可以在框架定义上使用HasShadow="True" 属性。

      你把HasShadow放在哪里了?应该是这样的

      <i> <Frame HasShadow="True" ...> </Frame> </i> 
      

      【讨论】:

        猜你喜欢
        • 2011-07-19
        • 2021-07-15
        • 1970-01-01
        • 2017-07-19
        • 1970-01-01
        • 1970-01-01
        • 2013-02-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多