在我的活动类中,我使用自定义键盘和android软文本键盘。Android文本软键盘调整活动布局。如果我打开自定义键盘,而软键盘打开,最后一个隐藏和布局扩大回来。但我一打完电话就会打开定制键盘
InputMethodManager imm = (InputMethodManager)context.GetSystemService(Context.InputMethodService);
imm.HideSoftInputFromWindow(view.WindowToken, 0);这里的视图是带有自定义键盘的视图。当定制键盘绘制两次时,我面临的问题是:
我想要做的是避免两个键盘同时出现。在活动代码中,我只使用SoftInput.StateAlwaysHidden WindowSoftInputMode。SoftInput.AdjustPan并不方便,因为在这种情况下,一些视图可以被安卓键盘隐藏。
发布于 2016-11-28 11:48:07
经过数小时的网络搜索,答案终于找到了。Pspdfkit有伟大的职位。
通过小规模的调查,它在C#上被改写为Oncreate方法:
private View decorView;
private int lastVisibleDecorViewHeight = 0;
decorView = Window.DecorView;
decorView.ViewTreeObserver.GlobalLayout += (sender, args) =>
{
Rect windowVisibleDisplayFrame = new Rect();
decorView.GetWindowVisibleDisplayFrame(windowVisibleDisplayFrame);
int visibleDecorViewHeight = windowVisibleDisplayFrame.Height();
if (lastVisibleDecorViewHeight != 0)
{
if (lastVisibleDecorViewHeight > visibleDecorViewHeight)
{
OnSoftKeyboardShown();
}
else if (lastVisibleDecorViewHeight < visibleDecorViewHeight)
{
OnSoftKeyboardHidden();
if (!isAndroidSoftKeyboardShown && customKeyboardRequested)
{
Keyboard.RequestCustomKeyboard(requestedCustomKeyboardType);
customKeyboardRequested = false;
}
}
}
lastVisibleDecorViewHeight = visibleDecorViewHeight;
};希望这能对有类似问题的人有所帮助。
https://stackoverflow.com/questions/40787967
复制相似问题