Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 在sencha touch 2中更改方向时更改大小转盘_Extjs_Sencha Touch_Touch_Orientation_Carousel - Fatal编程技术网

Extjs 在sencha touch 2中更改方向时更改大小转盘

Extjs 在sencha touch 2中更改方向时更改大小转盘,extjs,sencha-touch,touch,orientation,carousel,Extjs,Sencha Touch,Touch,Orientation,Carousel,我把旋转木马放在集装箱里 在portrail模式下,我将高度设置为150,图像在旋转木马中全屏显示。 但当我切换到横向时,图像的两侧有两个白色空白 我想通过设置另一个高度值来更改旋转木马的大小。你能帮我解决这个问题吗 您需要捕获方向更改事件 ()并在捕获它时调用一个函数,该函数将调整容器的大小 您可以尝试以下方法: Ext.Viewport.on('orientationchange', 'handleOrientationChange', this); 然后在handle函数中设置所需的组

我把旋转木马放在集装箱里

  • 在portrail模式下,我将高度设置为150,图像在旋转木马中全屏显示。 但当我切换到横向时,图像的两侧有两个白色空白

  • 我想通过设置另一个高度值来更改旋转木马的大小。你能帮我解决这个问题吗


您需要捕获方向更改事件 ()并在捕获它时调用一个函数,该函数将调整容器的大小

您可以尝试以下方法:

Ext.Viewport.on('orientationchange', 'handleOrientationChange', this);
然后在handle函数中设置所需的组件尺寸:

handleOrientationChange: function(){
    Ext.getCmp('idOfMyContainer').setWidth('480px'); //or setHeight() depending on the real problem
}
您还可以根据屏幕的实际大小设置宽度和高度,这可以通过调用这些方法获得。请注意,方向更改不会影响这些的返回值,因此需要手动切换:

Ext.Viewport.getWindowWidth();
Ext.Viewport.getWindowHeight()

可以使用Ext.Viewport.getOrientation()获取当前方向(纵向或横向),然后根据视口的新宽度/高度更新任何组件