我的Relativelayout将不会显示在FrameLayout下
enter image description here好所以,我制作了fragment_googlemap.xml,并且我将FrameLayout设计为根布局,因为我需要将mapView作为片段。切入正题,我想要发生的事情是在谷歌地图的顶部显示微调和浮动操作按钮。但是当我运行该应用程序时,我看不到相关布局的孩子(微调和浮动按钮)。我认为这是在googlemapview下,因为我可以在加载时在googlemap下看到它们一秒。 任何解决方案?我的Relativelayout将不会显示在FrameLayout下
OOOHH和BTW我不知道为什么抬高属性的值在浮动按钮不起作用任何想法请?
很抱歉,如果我的英语很差:(和THX提前!!!
=======这里是低于===========
我的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>
试试这个
FloatingActionButton
使用app:elevation="6dp"
insted的的android:elevation="6dp"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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>
<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_alignParentTop="true"
android:layout_margin="10dp"
android:backgroundTint="@color/colorPrimary"
android:elevation="6dp"
android:src="@drawable/ic_info_black_24dp"
android:tint="#000000"
app:borderWidth="0dp"
app:rippleColor="#eF43ef" />
<Spinner
android:id="@+id/spinner_countries"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignRight="@+id/fab"
android:layout_below="@+id/fab"
android:entries="@array/myarray" />
</RelativeLayout>
如果亲属匹配父亲,那么地图不会显示为线性布局的方向是垂直的,并且屏幕空间已被相对布局覆盖。 –
在这种情况下会比FrameLayout更好吗? – poream3387
@ poream3387检查更新ans –
你可以这样认为FrameLayout
作为LinearLayout
,但它堆积在彼此的俯视图。布局中的最后一个视图将屏幕上的俯视图。
,如果你想把东西放在你的MapView
之上,你应该把这些视图标签后<MapView>
标签。
WORKED THX !!!!!!!!!!!! – poream3387
你可以只是把MapView
新RelativeLayout
里面,试试这个。
<?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="wrap_content"
android:layout_height="wrap_content"
>
<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>
<RelativeLayout
android:id="@+id/spinner_countries"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<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>
</RelativeLayout
</FrameLayout>
您实际上应该添加地图视图首先,然后将浮动按钮作为框架布局的子项,如儿童视图绘制在堆栈中,最近添加的子项位于顶部 –
尝试这个
<?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">
<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>
<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>
框架布局必须只有1名儿童。在放入framelayout之前,将您的相对布局和地图放在另一个布局中。 – Lcukerd
在框架布局中,子视图以堆栈形式绘制,最近添加的子项位于顶层。所以在你的情况下,最近添加的孩子是mapview,这就是为什么你的微调和浮动按钮在你的地图背后。颠倒顺序,它会很好。 –
什么是最好的布局?把它们放在一起? – poream3387