Xamarin表单:是否可以在Android中添加披露指标?
我有一个Xamarin表单:是否可以在Android中添加披露指标?,android,xamarin,xamarin.forms,Android,Xamarin,Xamarin.forms,我有一个TextCell,它在我的Xamarin表单应用程序的iOS端添加了一个披露指示器: <TextCell Text="Japanese" StyleId="disclosure"/> 我也想为android端做同样的事情,但我似乎找不到任何自定义渲染器来做这样的事情 有人能做到这一点吗?如果有人能给我指出这个方向,我将不胜感激。根据,建议不要在Android中的行项目上使用右指插入符号(披露指示器) 不要在行项目上使用右指插入符号 其他平台上的一种常见模式是在行项目上显
TextCell
,它在我的Xamarin表单
应用程序的iOS端添加了一个披露指示器:
<TextCell Text="Japanese" StyleId="disclosure"/>
我也想为android端做同样的事情,但我似乎找不到任何自定义渲染器来做这样的事情
有人能做到这一点吗?如果有人能给我指出这个方向,我将不胜感激。根据,建议不要在Android中的行项目上使用右指插入符号(披露指示器)
不要在行项目上使用右指插入符号
其他平台上的一种常见模式是在行项目上显示右指插入符号,使用户可以更深入地钻研其他内容
Android不在深入行项目上使用此类指示器。避免它们与平台保持一致,以免让用户猜测这些插入符号的含义
编辑1:
但是,如果您仍然想添加指示器,可以使用图像进行添加
并添加为可绘制到android项目。并按如下方式注册渲染器:
[assembly: ExportRenderer(typeof(TextCell), typeof(StandardTextCellRenderer))]
namespace AppNamespace.Droid
{
public class StandardTextCellRenderer : TextCellRenderer
{
protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context)
{
var cell = base.GetCellCore(item, convertView, parent, context);
switch (item.StyleId)
{
case "disclosure":
var bmp = BitmapFactory.DecodeResource(cell.Resources, Resource.Drawable.ic_chevron_right);
var bitmapDrawable = new BitmapDrawable(cell.Resources, Bitmap.CreateScaledBitmap(bmp, 50, 50, true));
bitmapDrawable.Gravity = GravityFlags.Right | GravityFlags.CenterVertical;
cell.SetBackground(bitmapDrawable);
break;
}
return cell;
}
}
}