gpt4 book ai didi

android - Google Map Fragment 和 AdMob, map 位置按钮在广告下方

转载 作者:行者123 更新时间:2023-11-29 15:57:49 26 4
gpt4 key购买 nike

您好,我有一个布局,顶部有一个菜单栏,然后​​是 map fragment 和 AdMob 横幅。它几乎都按需要显示,除了出于某种原因,MapFragment 中的“获取位置”按钮大部分隐藏在 adMob 横幅下方。即使 map 确实在横幅上方结束,“获取位置”按钮也会被剪掉。任何帮助将不胜感激 AdFragment 是 AdMob 横幅示例的精确复制品(包裹在 AdView 元素周围的 RelativeLayout)。这是我的布局的样子,我们将不胜感激。我还注意到,如果我将 adFragment 替换为 RelativeLayout,则“我的位置”按钮不会被剪裁,但不成比例以适应 map 屏幕

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mapScreen"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
android:id="@+id/layoutTop"
android:layout_width="match_parent"
android:layout_height="45dp">
</RelativeLayout>
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_height="0dp"
android:layout_weight="1"/>
<fragment
android:id="@+id/adFragment"
android:name="xxxx$AdFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>



</LinearLayout >

最佳答案

你的主要问题是你已经告诉 mapmatch_parent 的高度。

我怀疑您的 Intent 是让 map 扩展以填充 layoutTopadFragment 之间的空间。如果是这样,您最好使用带有 layout_weight="1" 的 LinearLayout 用于 map,如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mapScreen"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
android:id="@+id/layoutTop"
android:layout_width="match_parent"
android:layout_height="45dp">
</RelativeLayout>

<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>

<fragment
android:id="@+id/adFragment"
android:name="xxxx$AdFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</LinearLayout>

关于android - Google Map Fragment 和 AdMob, map 位置按钮在广告下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26836607/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com