【发布时间】:2017-09-14 04:24:50
【问题描述】:
enter image description hereOK 所以,我制作了 fragment_googlemap.xml 并将 FrameLayout 设计为根布局,因为我需要将 mapView 作为片段。切入正题,我想做的是在谷歌地图的顶部显示 Spinner 和 Floating Action Button。但是当我运行应用程序时,我看不到 relativelayout 的子项(微调器和浮动按钮)。我认为它在 googlemapview 下,因为加载时我可以在 googlemap 下看到它们一秒钟。 有什么解决办法吗?
OOOHH 和顺便说一句,我不知道为什么浮动按钮中的海拔属性值不起作用任何想法??
对不起,如果我的英语很差:(提前谢谢!!!
=======下面是我的xml文件源代码===========
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Spinner
android:id="@+id/spinner_countries"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/fab"
android:layout_below="@+id/fab"
android:entries="@array/location_arraysResc" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_gravity="end|top"
android:layout_margin="10dp"
android:backgroundTint="@color/colorPrimary"
android:elevation="6dp"
android:src="@drawable/paperplane"
android:tint="#000000"
app:borderWidth="0dp"
app:rippleColor="#eF43ef" />
</RelativeLayout>
<com.google.android.gms.maps.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.google.android.gms.maps.MapView>
</FrameLayout>
【问题讨论】:
-
框架布局必须只有 1 个子级。在放入 framelayout 之前,将您的相对布局和地图放入另一个布局中。
-
在框架布局中子视图绘制在堆栈中,最近添加的子视图在顶部。因此,在您的情况下,最近添加的子项是 mapview,这就是为什么您的微调器和浮动按钮位于地图后面的原因。把顺序反过来就好了。
-
最好的布局是什么?把它们放在一起?
-
@Lcukerd 不一定要有一个孩子,但为了正确组织孩子,它应该有一个视图。
-
是的,颠倒了订单WOORKED !!!!!!!!!谢了!
标签: android android-layout android-relativelayout android-framelayout