首先,我知道SlidingDrawer已被弃用,但我没有找到任何替代品,所以我仍在使用它:3(如果有人知道替代它,请分享它!)
所以我的活动中有一个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>
答案 0 :(得分:55)
将地图放在相对布局中。在地图前面有一个相同尺度的视图。
示例:
<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>