Can';Android地图上的t覆盖按钮
我试着从其他同样问题的问题中寻找答案,但没有一个对我有帮助 我只需要在谷歌地图上加一个按钮 代码如下:Can';Android地图上的t覆盖按钮,android,google-maps,android-fragments,google-maps-android-api-2,Android,Google Maps,Android Fragments,Google Maps Android Api 2,我试着从其他同样问题的问题中寻找答案,但没有一个对我有帮助 我只需要在谷歌地图上加一个按钮 代码如下: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="match_parent"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#ffffff">
<fragment 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:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.henriquevoni.petgo.MapFragment"/>
<Button
android:id="@+id/button7"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="end|center_horizontal"
android:layout_marginBottom="39dp"
android:layout_marginLeft="8dp"
android:background="#359c5e"
android:text="Next"
android:textColor="#ffffff"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
这是一个你能这样试试吗
<FrameLayout 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">
<fragment 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:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:context="com.henriquevoni.petgo.MapFragment"/>
<Button
android:id="@+id/button7"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="39dp"
android:layout_marginLeft="8dp"
android:background="#359c5e"
android:text="Next"
android:textColor="#ffffff"
/>
</FrameLayout>
或者你也可以这样做
<FrameLayout 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">
<fragment 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:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:context="com.henriquevoni.petgo.MapFragment"/>
<Button
android:id="@+id/button7"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="39dp"
android:layout_marginLeft="8dp"
android:background="#359c5e"
android:text="Next"
android:textColor="#ffffff"
/>
</FrameLayout>
如果这是您想要的…只需在片段中添加按钮
<FrameLayout 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">
<fragment 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:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:context="com.henriquevoni.petgo.MapFragment">
<Button
android:id="@+id/button7"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="39dp"
android:layout_marginLeft="8dp"
android:background="#359c5e"
android:text="Next"
android:textColor="#ffffff"
/>
</fragment>
</FrameLayout>
使用Android Studio的布局检查器查看按钮的收尾位置。在父级相对位置上,尝试更改布局宽度以匹配父级。您的片段正在占用整个屏幕。因此,按钮被按下。我相信,如果你想“在碎片上”的话,先把按钮放在上面