我在XF中使用Android平台的自定义背景的条目。当它聚焦时,键盘覆盖了底线。
public class MessageEntryRenderer : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (e.OldElement != null || this.Element == null)
return;
Control.Gravity = DefaultGravity;
var MessageEntry = Element as MessageEntry;
UpdateBackground(MessageEntry);
...
}
private void UpdateBackground(MessageEntry MessageEntry)
{
if (_renderer != null)
{
_renderer.Dispose();
_renderer = null;
}
_renderer = new BorderRenderer();
//Set to background object of type GradientDrawable
Control.SetBackground(_renderer.GetBorderBackground(MessageEntry.BorderColor, MessageEntry.BackgroundColor, MessageEntry.BorderWidth, MessageEntry.BorderRadius));
} }
图片:带有边界的条目键盘覆盖底部 我需要显示底线。我试图添加这样的填充: private void UpdatePadding(MessageEntry MessageEntry)
{ Control.SetPadding((int)Forms.Context.ToPixels(MessageEntry.LeftPadding), 10,
(int)Forms.Context.ToPixels(MessageEntry.RightPadding), 0);
但这是输入文字的填充。
}
我修复了它。问题在于入口填充。底部和顶部为0。我将其设置为如下所示:
private void UpdatePadding(MessageEntry MessageEntry)
{
Control.SetPadding((int)Forms.Context.ToPixels(MessageEntry.LeftPadding), Control.PaddingTop/3,
(int)Forms.Context.ToPixels(MessageEntry.RightPadding), Control.PaddingTop/3);
}