繁体   English   中英

如何以 xamarin 形式为框架提供阴影效果

[英]How to give a shadow effect to a frame in xamarin forms

我是 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>

代码给出了这个输出

在此处输入图片说明

但我想要这样的页面在此处输入图片说明

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

亚历克斯·邓恩 (Alex Dunn) 的这篇文章看起来正是您想要的: 在此处输入图片说明 https://alexdunn.org/2018/06/06/xamarin-tip-dynamic-elevation-frames/

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

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

你把HasShadow放在哪里了? 它需要像这样

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM