在地图上查看顶部,同时用DrawerLayout使用它消失 [英] View on top of map disappears while using it with a DrawerLayout

查看:403
本文介绍了在地图上查看顶部,同时用DrawerLayout使用它消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建其中包含地图(com.google.android.gms.maps.SupportMapFragment)及布局;迷你布局进入原点&安培;目的地(pickup_dropoff_LL的LinearLayout)。

I'm creating a layout which contains a maps (com.google.android.gms.maps.SupportMapFragment) & a mini layout to enter origin & destination(pickup_dropoff_LL LinearLayout).

XML

<RelativeLayout
    android:id="@+id/main_RL"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/rideType_LL">

        <include
            android:id="@+id/pickup_dropoff_LL"
            layout="@layout/layout_pickup_dropoff"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="10dp" />

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        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=".MapsActivity" />

</RelativeLayout>

最初,这有一个相应的活动但是我已经向大家介绍一个DrawerLayout所以我不得不将其转换为一个片段。

Initially this had a corresponding Activity but I had to introduce a DrawerLayout so I had to convert it to a Fragment.

这样做,我pickup_dropoff_LL消失后。
这是显示在屏幕上的微秒钟,然后消失

After doing that my pickup_dropoff_LL disappears. It is shown on the screen for a micro second and then it disappears.

我怀疑的问题是什么地方在这里,但我不知道。

I suspect the issue is somewhere here but I'm not sure.

SupportMapFragment fm;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.activity_main_activity, container, false);

    fm = new SupportMapFragment() {
        @Override
        public void onActivityCreated(Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
            map = fm.getMap();
            if (map != null) {
                map.setMyLocationEnabled(true);
                fm.getMapAsync(MainActivity2.this);


            }
        }
    };
    getChildFragmentManager().beginTransaction().add(R.id.main_RL, fm).commit();

    return rootView;
}

1 我检查能见度pickup_dropoff_LL。它显示为0,这意味着View.VISIBLE。但它是不可见的。

1. I checked visibility for pickup_dropoff_LL. It's showing as 0, which means View.VISIBLE. But it is not visible.

2 :由一些链接的建议,我试着将同一高度和放一个空的观点。宽度在我的地图。即使是没有工作。

2. As suggested by some links, I tried placing an empty view of same height & width over my map. Even that didn't work.

那么,如何停止从消失的看法?请帮助。

So how do I stop the view from disappearing?? Please help.

推荐答案

试着画布局最后。把包含片段

Try drawing your layout last. Put the Include after the Fragment

<RelativeLayout
    android:id="@+id/main_RL"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/rideType_LL">

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        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=".MapsActivity" />

        <include
            android:id="@+id/pickup_dropoff_LL"
            layout="@layout/layout_pickup_dropoff"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="10dp" />
</RelativeLayout>

这篇关于在地图上查看顶部,同时用DrawerLayout使用它消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆