【问题标题】:MapView rotation / orientation issueMapView 旋转/方向问题
【发布时间】:2012-07-03 06:33:57
【问题描述】:

我正在研究 MapActivity,它在地图的顶部、底部和侧面有一些额外的字段。所有这些 View 组件都在一个 main.xml 文件中可用。对于两个方向,我都有 layout-land 和 Portrait 目录,两个文件夹都包含具有相同 ID 的 main.xml。

我在 androidManifest.xml 中使用了 android:ConfigChaneg,并且我覆盖了方法 onConfigChange(Configuration newConfig)

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setContentView(R.layout.main);
    }
    else if(newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        setContentView(R.layout.main);
    }
}

但是现在当屏幕旋转/改变方向时出现异常。 MapActivity只能有一个MapView如何解决这个问题,请指导一下。

提前谢谢....

【问题讨论】:

    标签: android android-mapview android-orientation


    【解决方案1】:

    如果您想在一种模式下修复屏幕,您可以在 Manifest 文件中修复屏幕 在活动中添加属性 android:screenOrientation="portrait" 或者当你的 onConfigurationChanged 在这里以两种模式重新启动所有进程时

    【讨论】:

    • 你需要两个方向吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-07
    • 1970-01-01
    • 1970-01-01
    • 2010-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多