`

sencha touch form field 随键盘弹而自适应

阅读更多

  使用sencha touch form里的field的组件,我们都会遇到这种情况,当一个表单中的field过多时,会向下撑满整个屏幕,这是如果点击靠屏幕下方的field组件,那么弹出的系统输入法会把form字段给遮挡住,这种用户体验非常不好。如果能在输入框展开时,自动调整field的展示位置就好了。

  使用如下配置:

{
    xtype: 'textareafield',
    name: 'bio',
    label: 'Bio',
    maxRows: 10,
    listeners: {
        focus: function(comp, e, eopts) {
            var ost = comp.element.dom.offsetTop;
            this.getParent().getParent().getScrollable().getScroller().scrollTo(0, ost);
        }
    }
}

 注意focus事件里的“this.getParent().getParent()”完成的功能是找到父级容器的form层,这个可以根据自己代码层级做调整。

 

原文摘自:http://stackoverflow.com/questions/15596111/sencha-touch-2-1-form-panel-keyboard-hides-active-textfield-on-android

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics