【发布时间】:2011-08-08 09:41:22
【问题描述】:
我正在尝试使用此示例在 MapView 上创建一个从左到右的滑动抽屉:
http://www.anddev.org/viewtopic.php?p=16622
但它将屏幕分成两部分,上侧 MapView,第二部分显示滑动抽屉。
请建议我如何在地图上创建一个侧滑抽屉..
我的 result.xml 如下所示:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:panel="http://schemas.android.com/apk/res/com.app.SL"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#767c9b"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.google.android.maps.MapView
android:id="@+id/myGMap" android:layout_width="fill_parent"
android:enabled="true" android:clickable="true"
android:apiKey="0cgwXB2sO7JjQpz_Ho3KFg60hJSL3GjWWAC4yQA"
android:layout_height="343dp" android:layout_weight="1.26" />
<com.app.SL.Panel
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/leftPanel2"
android:layout_weight="1"
android:layout_gravity="left"
panel:position="left"
panel:openedHandle="@drawable/left_switcher_expanded_background"
panel:closedHandle="@drawable/left_switcher_collapsed_background"
>
<Button
android:id="@id/panelHandle"
android:layout_width="33dip"
android:layout_height="fill_parent"
/>
<TextView
android:id="@id/panelContent"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center"
android:padding="4dip"
android:text="This is\nmy second\nleft Panel"
android:textSize="16dip"
android:textColor="#eee"
android:textStyle="bold"
android:background="#115544"
/>
</com.app.SL.Panel>
</LinearLayout>
</FrameLayout>
【问题讨论】:
-
谢谢 hanry..但是我想实现滑动抽屉拖开功能..所有三个链接都不是为了那个..第一个看起来像滑动抽屉但是..就是这样改变可见性...
-
@jiya 首先将布局更改为放置地图的相对。 LinearLayout 的问题是您忘记放置权重。将 android:layout_weight="1" 赋予 mapview 和 android:layout_weight="0" 面板布局。
-
非常感谢 hanry..我通过将线性布局更改为相对布局获得了理想的结果...您的评论实际上是我的答案..;)
-
@jiya Any 你是怎么知道的......
标签: android android-layout android-mapview slidingdrawer