简体   繁体   English

键盘显示时,离子离子含量不会向下滚动(Android)

[英]Ionic ion-content not scrolling down when keyboard shows (Android)

I have a simple view with a login form. 我有一个登录表单的简单视图。 On Android, if the keyboard is opened, the content is not scrolling up to prevent it from getting behind the keyboard. 在Android上,如果打开键盘,则内容不会向上滚动以防止它进入键盘后面。

I followed the Keyboard instructions from the docs, and read a lot of forum posts, but I haven't figured it out. 我按照文档中的键盘说明,阅读了很多论坛帖子,但我还没弄明白。

I installed the Keyboard plugin com.ionic.keyboard . 我安装了Keyboard插件com.ionic.keyboard

This is the structure of the page: 这是页面的结构:

<ion-nav-view>
  <ion-view>
    <ion-content>
       ...<form>..Login form..</form>...
    </ion-content>
  </ion-view>
</ion-nav-view>

If I put some extra dummy content in the page, it shows that ion-content is indeed scrollable. 如果我在页面中添加了一些额外的虚拟内容,则表明离子内容确实是可滚动的。 However, it's not moving up when the keyboard is opened by focusing on an input. 但是,当通过聚焦输入打开键盘时,它不会向上移动。

  • Ionic version? 离子版? 1.0.0-beta.13
  • Is my app fullscreen? 我的应用是全屏吗? No 没有
  • Did I test if the keyboard plugin is working? 我是否测试过键盘插件是否正常工作? Yes

Is there anything else I have to do? 还有什么我必须做的吗?

In the section where you declare the keyboard plugin, try to add this: 在声明键盘插件的部分中,尝试添加以下内容:

  if (window.cordova && window.cordova.plugins.Keyboard) {
    cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    cordova.plugins.Keyboard.disableScroll(false);

  }

I have prevent this scrolling property in my project by setting below values in AndroidManifest.xml file. 我通过在AndroidManifest.xml文件中设置以下值来阻止我的项目中的滚动属性。

android:windowSoftInputMode = "adjustNothing"

Please check whether android:windowSoftInputMode value is adjustResize or not in AndroidManifest.xml . 请检查AndroidManifest.xml中 android:windowSoftInputMode值是否为adjustResize If not please update it to adjustResize . 如果没有,请将其更新为adjustResize

I hope this will you. 我希望你能。 Thanks 谢谢

On both Android and iOS, Ionic will attempt to prevent the keyboard from obscuring inputs and focusable elements when it appears by scrolling them into view. 在Android和iOS上,Ionic将尝试通过将键盘滚动到视图中来防止键盘在显示时隐藏输入和可聚焦元素。 In order for this to work, any focusable elements must be within a Scroll View or a directive such as Content that has a Scroll View. 为了实现这一点,任何可聚焦元素都必须位于Scroll View或指令中,例如具有Scroll View的Content。

description from documentation here 这里的文档描述

In my case there is a footer that hides the input when the keyboard is showing. 在我的情况下,有一个页脚在键盘显示时隐藏输入。

Seeing github.com/driftyco/ionic/issues/2151 , although its a closed bug it seems that its still an issue. 看到github.com/driftyco/ionic/issues/2151 ,虽然它是一个封闭的bug,但似乎它仍然是一个问题。

To me it seems that the scrolling doesn't know how to calculate properly whether it should scroll or not, because it doesn't take under account the footer in its calculations. 对我来说,似乎滚动不知道如何正确计算它是否应该滚动,因为它不会在计算中考虑页脚。 If the content is big enough from the first place then it knows it has to scroll anyway. 如果内容从第一个位置足够大,那么它知道它必须滚动。

I've ended up using 我最终用完了

$timeout(function() {
    $ionicScrollDelegate.scrollBottom(true);
}, 300);

and adding some <br/> at the bottom of my ion-content . 并增加了一些<br/>在我的底部ion-content There is enough space so it won't effect anything for me, bug will cause the scroll to work properly. 有足够的空间,所以它不会对我有任何影响,bug将导致滚动正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM