Android的图形页面重叠DrawerLayout [英] Android MapView overlaps DrawerLayout

查看:335
本文介绍了Android的图形页面重叠DrawerLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有简单的布局结构:

  DrawerLayout
\  - 的FrameLayout // @ + ID / fragment_container
\  -  ListView的// @ + ID / drawer_list
 

点击任何抽屉里的项目,我插入的/通过 FragmentTransaction.replace替换片段() R.id.fragment_container 相应片段实例。其中的一个片段包含图形页面

和它呈现在不同设备上的问题,但在同一时间DDMS显示我的权利截图。

EDITED

问题出现在这些设备上:

  • 华为U9508 的Andr​​oid 4.0.4(API 15)
  • HTC渴望A9191 的Andr​​oid 2.3.5(API 10)

没问题在这些设备上:

  • 三星Galaxy S2 与的CyanogenMod的Andr​​oid 4.2.2(API 17)
  • LG谷歌Nexus 4 的Andr​​oid 4.3(API 18)

任何人可以帮助我了解和解决这个问题?

看到的影像:

华为U9508 的Andr​​oid 4.0.4(API 15)

HTC渴望A9191 的Andr​​oid 2.3.5(API 10)

DDMS

EDITED

活动的布局:

 < XML版本=1.0编码=UTF-8&GT?;
< D​​rawerLayout
        的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        机器人:ID =@ + ID /抽屉
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent
        >

    <! - 其主要内容视图 - >
    <的FrameLayout
            机器人:ID =@ + ID / fragment_container
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent
            />

    <! - 导航抽屉 - >
    <的ListView
            机器人:ID =@ + ID / drawer_list
            机器人:layout_width =240dp
            机器人:layout_height =match_parent
            机器人:方向=垂直
            />
< / DrawerLayout>
 

片段布局:

 < XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的
        的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        >

    <! - 其他意见在这里 - >

    < com.google.android.gms.maps.MapView
            机器人:ID =@ + ID / consumer_profile_map
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent
            />
< / RelativeLayout的>
 

解决方案

于是,我找到的解决方法解决方法:只是包装图形页面入容器中,放置空查看上方。多亏了这样的回答:<一href="http://stackoverflow.com/a/16231935/1891118">http://stackoverflow.com/a/16231935/1891118

还有就是我更新的布局:

 &LT;的FrameLayout
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent
        &GT;

    &LT; com.google.android.gms.maps.MapView
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent
            /&GT;

    &LT;查看
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent
            /&GT;
&LT; /的FrameLayout&GT;
 

I have simple layout structure:

DrawerLayout
\-- FrameLayout // @+id/fragment_container
\-- ListView    // @+id/drawer_list

By clicking of any drawer item I'm inserting/replacing fragment via FragmentTransaction.replace() into R.id.fragment_container with corresponding Fragment instance. One of those Fragments contains MapView.

And it has rendering problems on different devices, but at the same time DDMS shows me right screenshot.

EDITED

Issue appears on such devices:

  • Huawei U9508, Android 4.0.4 (API 15)
  • HTC Desire A9191, Android 2.3.5 (API 10)

There is no issue on such devices:

  • Samsung Galaxy S2 with CyanogenMod Android 4.2.2 (API 17)
  • LG Google Nexus 4 Android 4.3 (API 18)

Could anybody help me to understand and fix this problem?

See images:

Huawei U9508, Android 4.0.4 (API 15)

HTC Desire A9191, Android 2.3.5 (API 10)

DDMS

EDITED

activity layout:

<?xml version="1.0" encoding="utf-8"?>
<DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/drawer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

    <!-- The main content view -->
    <FrameLayout
            android:id="@+id/fragment_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />

    <!-- The navigation drawer -->
    <ListView
            android:id="@+id/drawer_list"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:orientation="vertical"
            />
</DrawerLayout>

fragment layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >

    <!-- other views here -->

    <com.google.android.gms.maps.MapView
            android:id="@+id/consumer_profile_map"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />
</RelativeLayout>

解决方案

So, I find workaround solution: just wrap MapView into container and place empty View above. Thanks to this answer: http://stackoverflow.com/a/16231935/1891118

There is my updated layout:

<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

    <com.google.android.gms.maps.MapView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />

    <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />
</FrameLayout>

这篇关于Android的图形页面重叠DrawerLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆