将WindowSoftInputMode设置为AdjustPan时出现问题 [英] Issue while setting WindowSoftInputMode to AdjustPan

查看:634
本文介绍了将WindowSoftInputMode设置为AdjustPan时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究Xamarin表单项目.我的应用程序中有很多输入"字段,其中一个位于弹出窗口中,并且该弹出窗口在设备屏幕的中央打开.滚动视图中也很少有输入字段.此问题仅与Android应用程序有关.对于iOS,它可以完美运行. 当我单击弹出窗口旁边的Entry字段时,将打开软键盘,并且弹出窗口的UI会受到干扰.所以,我决定设定 WindowSoftInputMode = SoftInput.AdjustPan 进入我的主要活动.这解决了我的弹出窗口的UI问题,但是现在当我单击其他输入字段时,我的![滚动视图停止滚动] (很少的输入字段位于侧面的滚动视图中).其他软输入,但没有用. 关于如何摆脱这一点的任何想法?

I’m working on Xamarin forms project. I’ve many Entry fields in my application, one of them is in popup and the popup opens in the centre of the device screen. Also few entry fields are in scroll view. The issue is only with the Android Application. For iOS it’s working perfectly. When I click on Entry field in side the popup, the soft key board is opened and the UI of my popup gets disturbed. So, I decided to set WindowSoftInputMode = SoftInput.AdjustPan to my main Activity. This solves my UI issue of the popups but now when I click on other entry fields,my ![scroll view stops scrolling] (few entry fields are in side scrollview).I tried by using AdjustResize and rest of other soft inputs, but of no use. Any ideas on how to get rid of this ?

推荐答案

在Android Xamarin.Forms应用程序上运行的是一个Android Activity,因此WindowSoftInputMode是全局设置的.您可以进行依赖项注入服务.在iOS上它什么也不做,在Android上它将WindowSoftInputMode设置为所需的值.然后在显示弹出窗口之前和之后使用它来设置WindowSoftInputMode.

On Android Xamarin.Forms Application is working on a single Android Activity, so WindowSoftInputMode is set globally. You could do a dependency injection service. On iOS it would do nothing and on Android it would set WindowSoftInputMode to your desired value. Then use it to set WindowSoftInputMode before and after showing your Popup.

在Xamarin中,表单Forms.Context是活动.

In Xamarin.Forms Forms.Context is the Activity.

var window = ((Activity)Forms.Context).Window;
window.SetSoftInputMode(SoftInput.AdjustPan);

这篇关于将WindowSoftInputMode设置为AdjustPan时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆