android-fragments 在Android Studio中自动生成的MapActivity中添加浮动按钮

wrrgggsh  于 2022-11-14  发布在  Android
关注(0)|答案(1)|浏览(136)

亲爱的,
我想添加一个浮动按钮到Map布局自动生成的Android工作室。我尝试了多种解决方案,但没有一个使按钮出现:它似乎总是在碎片后面显现出来。
我该如何解决这个问题呢?我想在Map右下方添加经典的圆形浮动按钮,而不创建底部栏。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">

<fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MapsActivity" />
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:visibility="visible">

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/moveCameraButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

想法?那应该是最后的结果

hivapdat

hivapdat1#

您正在将线性布局用作父布局,,线性布局未与视图重叠请尝试使用相对布局

相关问题