Xamarin

键盘遮挡

2018-12-06  本文已影响8人  ColeX

链接 : https://forums.xamarin.com/discussion/comment/356942#Comment_356942

iOS :

[assembly:ExportRenderer( typeof(CustomEditor), typeof(CustomEditorRenderer))]
namespace YourNameSpace.iOS
{
public class CustomEditorRenderer: EditorRenderer
{
    public ChatEntryRenderer()
    {   
        UIKeyboard.Notifications.ObserveWillShow ((sender, args) => {

            if (Element != null)
            {
                Element.Margin = new Thickness(0,0,0, args.FrameEnd.Height); //push the entry up to keyboard height when keyboard is activated
            }
        });

        UIKeyboard.Notifications.ObserveWillHide ((sender, args) => {

            if (Element != null)
            {
                   Element.Margin = new Thickness(0); //set the margins to zero when keyboard is dismissed
            }

        }); 
    }
}
}

Android :

App.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
上一篇 下一篇

猜你喜欢

热点阅读