我在特定设备(小米 Note7 Pro)上的输入字段出现问题,即当我尝试在输入字段中输入值时,将导致设备(小米 Note7 Pro)的 MIUI 重新启动。我已经进行了一些挖掘,但还没有找到任何解决方案。请帮我解决这个问题。
我也尝试在输入时更改键盘类型,但仍然没有成功。下面是入口控制 xaml 的示例:
<AbsoluteLayout>
<controls:ExtEntry x:Name="txtUsername"
Placeholder="Username"
Keyboard="Email"
Text="{Binding Username}"
Style="{StaticResource EntryImage}"/>
<Image Source="usericon"
Style="{StaticResource RightImageIcon}"/>
</AbsoluteLayout>
下面是我的 ExtEntry(渲染器)的代码:
public class CustomEntry : EntryRenderer
{
ExtEntry element;
public CustomEntry(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control == null || e.NewElement == null) return;
element = (ExtEntry)this.Element;
var editText = this.Control;
if (!string.IsNullOrEmpty(element.Image))
{
switch (element.ImageAlignment)
{
case ImageAlignment.Left:
editText.SetCompoundDrawablesWithIntrinsicBounds(
GetDrawable(element.Image), null, null, null);
break;
case ImageAlignment.Right:
editText.SetCompoundDrawablesWithIntrinsicBounds(
null, null, GetDrawable(element.Image), null);
break;
}
}
editText.CompoundDrawablePadding = 25;
// Control.Background.SetColorFilter(element.LineColor.ToAndroid(),
// PorterDuff.Mode.SrcAtop);
Control.FocusChange += Control_FocusChange;
if (element.IsBorderVisible)
{
GradientDrawable gd = new GradientDrawable();
gd.SetShape(ShapeType.Rectangle);
gd.SetCornerRadius(3);
gd.SetStroke(3, Android.Graphics.Color.Rgb(188, 196, 205));
Control.SetBackground(gd);
}
Control.CustomSelectionActionModeCallback = new Callback();
Control.SetPadding(10, 5, 10, 5);
Control.LongClickable = false;
}
protected override void OnElementPropertyChanged(object sender,
PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName.Equals(nameof(element.Image)))
{
var editText = this.Control;
if (!string.IsNullOrEmpty(element.Image))
{
switch (element.ImageAlignment)
{
case ImageAlignment.Left:
editText.SetCompoundDrawablesWithIntrinsicBounds(
GetDrawable(element.Image), null, null, null);
break;
case ImageAlignment.Right:
editText.SetCompoundDrawablesWithIntrinsicBounds(null, null,
GetDrawable(element.Image), null);
break;
}
}
editText.CompoundDrawablePadding = 25;
}
}
private void Control_FocusChange(object sender, FocusChangeEventArgs e)
{
if (Control.HasFocus)
{
if (element.IsBorderVisible)
{
GradientDrawable gd = new GradientDrawable();
gd.SetStroke(3, Android.Graphics.Color.Rgb(29, 74, 147));
Control.SetBackground(gd);
}
}
else
{
if (element.IsBorderVisible)
{
GradientDrawable gd = new GradientDrawable();
gd.SetStroke(3, Android.Graphics.Color.Rgb(188, 196, 205));
Control.SetBackground(gd);
}
}
}
private Drawable GetDrawable(string imageEntryImage)
{
int resID = Resources.GetIdentifier(imageEntryImage,
"drawable", this.Context.PackageName);
var drawable = ContextCompat.GetDrawable(this.Context, resID);
var bitmap = ((BitmapDrawable)drawable).Bitmap;
Drawable d = new BitmapDrawable(Resources, Bitmap.CreateScaledBitmap(bitmap,
element.ImageHeight, element.ImageWidth, true));
return d;
}
}
请有人帮我解决这个问题。我已经尝试了很多方法来解决这个问题,但还没有找到任何解决方案。