/// <summary> /// 设置文本输入框的最大长度限制 /// </summary> /// <param name="textView"></param> /// <param name="value"></param> public static void SetMaxLength(this TextView textView, int value) { if (value > 0) { textView.AddFilters(new InputFilterLengthFilter(value)); } else { var items = textView.GetFilters(); if (items.Any_Nullable(x => x.GetType() == typeof(InputFilterLengthFilter))) { var filters = items.Where(x => x.GetType() != typeof(InputFilterLengthFilter)).ToArray(); textView.SetFilters(filters); } } }