通过 GoogleMap 滑动抽屉

2023-12-21

首先,我知道 SlidingDrawer 已被弃用,但我还没有找到任何替代方案,所以我仍然使用它:3(如果有人知道它的替代方案,请分享!)

所以我的 Activity 中有一个 GoogleMap(实际上是一个片段,但这并不重要),并且在同一屏幕中有一个漂亮的 SlidingDrawer。它工作正常,但是当我打开或关闭地图上的滑动抽屉时,它开始表现得很奇怪。看起来地图想要留在滑动抽屉前面。当抽屉完全打开后,它又回到前面,一切正常。

有解决方法吗?我快疯了!

这是我的布局:

<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>

将地图放在相对布局内。地图前面有一个具有相同尺寸的视图。

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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

通过 GoogleMap 滑动抽屉 的相关文章

随机推荐