我想要做的是在MapFragment v2的左下角添加Button。MapFragment右下角的按鈕
問題是我的MapFragment在LinearLayout裏面,因爲它下面也有AdView,所以我不能使用父對象。
我的代碼:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.powa.Activites.MapActivity"
tools:ignore="MergeRootFrame">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
>
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:id="@+id/mailBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/map"
android:layout_alignLeft="@+id/map"
android:text="MAIL" />
</RelativeLayout>
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/map"
android:background="@color/black"
ads:adSize="SMART_BANNER"
ads:adUnitId="XOXOXOXO" />
當我使用它就像我的MapFragment不會出現在所有。
下圖所示。
_____________________
| |
| |
| |
| |
| MapFragment |
| |
| |
| |
| |
| {Button} |
|____________________|
| |
| AdView |
|____________________|
哦,那是太明顯了>。< 由於現在隊友般的魅力的作品設置爲
和MapFragment! – JakubW
不客氣。 –