Xamarin.forms 如何在xamarin表单中实现良好的类似cardview的布局
我在XAML中使用帧来实现卡片视图。但这种设计与谷歌应用程序卡片视图或任何其他应用程序卡片视图并不接近。此外,我没有看到一个很好的阴影在所有三个方面,而是它有一个假的阴影线 代码如下:Xamarin.forms 如何在xamarin表单中实现良好的类似cardview的布局,xamarin.forms,xamarin.android,frame,cardview,Xamarin.forms,Xamarin.android,Frame,Cardview,我在XAML中使用帧来实现卡片视图。但这种设计与谷歌应用程序卡片视图或任何其他应用程序卡片视图并不接近。此外,我没有看到一个很好的阴影在所有三个方面,而是它有一个假的阴影线 代码如下: <Frame Margin="0,20,0,0" IsClippedToBounds="True" HasShadow="True"> <Frame.OutlineColor>
<Frame Margin="0,20,0,0"
IsClippedToBounds="True"
HasShadow="True">
<Frame.OutlineColor>
<OnPlatform x:TypeArguments="Color"
Android="Gray"
iOS="Gray"></OnPlatform>
</Frame.OutlineColor>
<StackLayout Orientation="Horizontal" Spacing="0">
<Image Source="mf_tickets1.png" WidthRequest="30" HeightRequest="30" Aspect="AspectFill" VerticalOptions="Center"/>
<Label x:Name="showsummary" Text="Summary " TextColor="Black" FontSize="Medium" FontAttributes="Bold" VerticalOptions="Start" >
</Label>
<Image x:Name="SummageHideShowImage1" Source="{Binding SummageHideShowImage}" WidthRequest="30" HeightRequest="30"
Aspect="AspectFill" HorizontalOptions="EndAndExpand" VerticalOptions="Center" ></Image>
</StackLayout>
</Frame>
有没有其他方法可以实现良好的卡片视图布局,从而使我的应用程序成为高级应用程序?我对使用第三方NuGet软件包毫不犹豫。 我编写了一个自定义的帧渲染器,并分配了一个具有合适的标高、颜色和阴影的可绘制资源文件 自定义框架:
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Frame> e)
{
base.OnElementChanged(e);
if (e.NewElement != null && e.OldElement == null)
ViewGroup.SetBackgroundResource(Resource.Drawable.FrameRenderValue);
ViewGroup.Elevation = 6;
}
protected override void OnElementChanged(ElementChangedEventArgs e)
{
基础。一个要素发生变化(e);
if(e.NewElement!=null&&e.OldElement==null)
SetBackgroundResource(Resource.Drawable.FrameRenderValue);
视图组。高程=6;
}
FrameRenderValue.xml:
<item>
<shape android:shape="rectangle">
<solid android:color="#CABBBBBB" />
<corners android:radius="2dp" />
</shape>
</item>
<item
android:left="0.5dp"
android:right="0.5dp"
android:top="0dp"
android:bottom="0dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
<corners android:radius="2dp" />
</shape>
</item>
谢谢您可以参考以下内容: