【发布时间】:2012-07-07 17:42:21
【问题描述】:
当用户从横向旋转到纵向时,我现在在使用 android phonegap 应用程序时遇到了一个奇怪的问题,但反过来却没有。
当屏幕从横向旋转到纵向时,内容视口的高度似乎保持在之前的高度 - 但是视口的宽度会正确调整大小。以下图片试图更清楚地显示这一点:
旋转到
我看到了这个问题:Android Screen Orientation: Landscape Back to Portrait ...但是虽然接受的答案可能是正确的,但我并不完全确定那里要求的是什么。
我只有一个带有默认配置的layout/main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
我还尝试了一些方向检测脚本,看看是否有帮助 - 我已经尝试过:
var viewPortHeight = $(window).height();
alert (viewPortHeight+" x "+$(window).width());
var headerHeight = $('div[data-role="header"]').height();
var footerHeight = 0;
var contentHeight = viewPortHeight - headerHeight - footerHeight;
// Set all pages with class="page-content" to be at least contentHeight
$('div[class="page-content"]').css({'min-height': contentHeight + 'px'});
还有
var devInfo = new DeviceInformation();
devInfo.setOrientation(0);
time_column_count = Math.floor(viewport.height / 270);
devInfo.setResolution({
height : $(window).width(),
width : $(window).height()
});
但是 - 没有骰子。这里有什么想法吗?
更新
这似乎只是 ICS 设备上的问题 - 在遇到此问题的设备上,横向模式下实际上存在滚动问题。 JQM Scroll 用于在不同的 div 上启用滚动。
【问题讨论】:
-
你有没有尝试将 android:layout_weight="1" 添加到根视图?看来是布局问题..
-
这似乎没有任何作用......而且它只出现在 ICS 中真的很奇怪......
标签: android html cordova rotation portrait