SlidingDrawer过的GoogleMap [英] SlidingDrawer over GoogleMap

查看:150
本文介绍了SlidingDrawer过的GoogleMap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我知道SlidingDrawer是德precated,但我还没有发现有任何替代它,所以我用它反正:3(如果有人知道替代它,请分享! )

所以,我有我的活性的GoogleMap(实际上是一个片段,但也没关系),并在同一个屏幕一个很好的SlidingDrawer。它工作正常,但是当我打开或关闭slidingdrawer在地图上,它开始表现怪异。它看起来像地图想要的留在slidingdrawer面前。当抽屉被完全打开,然后又回到了前面,一切正常。

是否有解决方法吗?我越来越疯狂!

这是我的布局:

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:ID =@ + ID /窗口
    >
        <片段
            机器人:ID =@ + ID / hackedmap
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent
            类=com.google.android.gms.maps.SupportMapFragment/>

< SlidingDrawer
        机器人:ID =@ + ID /抽屉
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent
        机器人:CONTENT =@ + ID / drawercontent
        机器人:手柄=@ + ID / drawerhandle
        机器人:方向=横向
        >

        <的LinearLayout
            机器人:ID =@ ID / drawerhandle
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:后台=#00000000
            机器人:重力=中心>

            < ImageView的
                机器人:ID =@ + ID / slidingHandle
                机器人:layout_width =40dp
                机器人:layout_height =WRAP_CONTENT
                机器人:adjustViewBounds =真
                机器人:scaleType =fitEnd
                机器人:SRC =@可绘制/ sliding_handle/>
        < / LinearLayout中>

        <的LinearLayout
            机器人:ID =@ + ID / drawercontent
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =match_parent
            机器人:后台=#DD000000
            机器人:重力=center_horizo​​ntal |顶
            机器人:方向=垂直>

            <的TextView
                机器人:ID =@ + ID / selectednet
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_gravity =center_horizo​​ntal
                机器人:layout_margin =4DP
                机器人:文本=选择网络
                机器人:textAppearance =机器人:ATTR / textAppearanceLarge
                机器人:文字颜色=#02bceb/>

            <的ListView
                机器人:ID =@ + ID / passivelist
                机器人:layout_width =match_parent
                机器人:layout_height =match_parent
                机器人:choiceMode =singleChoice>
            < / ListView控件>
        < / LinearLayout中>
    < / SlidingDrawer>

< / RelativeLayout的>
 

解决方案

把地图的相对布局中。在地图上使用相同的衡量一个视图。

前面

例如:

 < RelativeLayout的
       机器人:layout_width =match_parent
       机器人:layout_height =WRAP_CONTENT>

                            <包括
                                机器人:layout_width =WRAP_CONTENT
                                机器人:layout_height =250dp
                                机器人:layout_weight =1
                                布局=@布局/ general_map_fragment/>

                             <查看
                                 机器人:ID =@ + ID / imageView123
                                 机器人:layout_width =match_parent
                                 机器人:layout_height =250dp
                                 机器人:背景=@色/透明/>


                        < / RelativeLayout的>
 

First of all, I know the SlidingDrawer is deprecated, but I haven't found any alternative to it so I'm using it anyways :3 (If someone knows an alternative to it, please share it!)

So I have a GoogleMap in my activity (actually a fragment but it doesn't matter), and a nice SlidingDrawer in the same screen. It works fine, but when I open or close the slidingdrawer over the map, it starts behaving weird. It looks like the map want's to stay in front of the slidingdrawer. When the drawer is fully opened, then it comes back to the front and everything is ok.

Is there a workaround for this? I am getting crazy!

here is my layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/window"
    >
        <fragment
            android:id="@+id/hackedmap"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            class="com.google.android.gms.maps.SupportMapFragment" />

<SlidingDrawer
        android:id="@+id/drawer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:content="@+id/drawercontent"
        android:handle="@+id/drawerhandle"
        android:orientation="horizontal" 
        >

        <LinearLayout
            android:id="@id/drawerhandle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#00000000"
            android:gravity="center" >

            <ImageView
                android:id="@+id/slidingHandle"
                android:layout_width="40dp"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:scaleType="fitEnd"
                android:src="@drawable/sliding_handle" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/drawercontent"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="#DD000000"
            android:gravity="center_horizontal|top"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/selectednet"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_margin="4dp"
                android:text="Select a network:"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#02bceb" />

            <ListView
                android:id="@+id/passivelist"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:choiceMode="singleChoice" >
            </ListView>
        </LinearLayout>
    </SlidingDrawer>

</RelativeLayout>

解决方案

Put the map inside of a relative layout. In front of the map a view with the same measure.

Example:

<RelativeLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content" >

                            <include
                                android:layout_width="wrap_content"
                                android:layout_height="250dp"
                                android:layout_weight="1"
                                layout="@layout/general_map_fragment" />

                             <View
                                 android:id="@+id/imageView123"
                                 android:layout_width="match_parent"
                                 android:layout_height="250dp"
                                 android:background="@color/transparent" />


                        </RelativeLayout>

这篇关于SlidingDrawer过的GoogleMap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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