我已经使用自定义渲染来以 xamarin 形式显示 IOS 和 android 的条目单元格。我可以更改单元格的背景颜色,但有没有办法将任何背景图像设置为条目单元格。还有如何隐藏默认的android入口单元格中的下栏线。
我在 PCl 中的自定义输入单元格:
<local:MyEntry Placeholder="Placeholder" PlaceholderColor="Grey" TextColor="Black"/>
我已经使用自定义渲染来以 xamarin 形式显示 IOS 和 android 的条目单元格。我可以更改单元格的背景颜色,但有没有办法将任何背景图像设置为条目单元格。还有如何隐藏默认的android入口单元格中的下栏线。
我在 PCl 中的自定义输入单元格:
<local:MyEntry Placeholder="Placeholder" PlaceholderColor="Grey" TextColor="Black"/>
是的,您可以将任何背景图像设置为条目单元格。
因为IOS
你需要这样做:
Control.BorderStyle = UITextBorderStyle.None;
UIImage img = UIImage.FromFile("ImageName.png");
Control.Background = img;
对于android
:
Control.Background = ContextCompat.GetDrawable(Context, Resource.Drawable.ImageName);
为了隐藏android
使用中的下划线:
Control.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
完成此操作后,您可以xaml
像这样调整条目单元格的背景图像的高度宽度:
<local:MyEntry Placeholder="placeholder" PlaceholderColor="Grey" TextColor="Black" WidthRequest="200" HeightRequest="50"/>