微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Xamarin表单:是否可以在Android中添加披露指标?

enter image description here

我有一个TextCell,它在我的Xamarin Forms应用程序的iOS端添加一个披露指示器:

<TextCell Text="Japanese" StyleId="disclosure"/>

我也想为android方面做同样的事情,但我似乎无法找到任何自定义渲染器来做这样的事情.

有没有人能够做到这一点?如果有人能指出我那个方向,我真的很感激.

解决方法

根据 design guidelines,建议不要在Android中的订单项上使用右指向的插入符号(披露指示符).

Don’t use right-pointing carets on line items

A common pattern on other platforms is the display of right-pointing carets on line items that allow the user to drill deeper into additional content.

Android does not use such indicators on drill-down line items. Avoid them to stay consistent with the platform and in order to not have the user guess as to what the meaning of those carets may be.

enter image description here

编辑1:

但是,如果您仍想添加指标,则可以使用图像.

Download the icon添加为drawable到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,true));
                    bitmapDrawable.Gravity = GravityFlags.Right | GravityFlags.CenterVertical;
                    cell.SetBackground(bitmapDrawable);
                    break;
            }
            return cell;
        }
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐