View On Top Of Map Disappears While Using It With A Drawerlayout
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).
Solution 1:
Try drawing your layout last. Put the Include
after the Fragment
<RelativeLayoutandroid:id="@+id/main_RL"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_above="@+id/rideType_LL"><fragmentxmlns: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" /><includeandroid: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>
Solution 2:
Have you tried moving your content inside of your drawer and not behind it?
<!-- Drawer Host inside the parent relative layout --><android.support.v4.widget.DrawerLayoutandroid:id="@+id/main_drawer"android:layout_width="match_parent"android:layout_height="match_parent"><!-- Hold Fragment here --><FrameLayoutandroid:id="@+id/frag_main_host"android:layout_width="match_parent"android:layout_height="wrap_content" /><!-- Drawer --><RelativeLayoutandroid:id="@+id/drawer_pane"android:layout_width="wrap_content"android:layout_height="match_parent"android:layout_gravity="start"><!-- Menu list for drawer --><ListViewandroid:id="@+id/menu_list"android:layout_height="match_parent"android:layout_width="280dp"android:dividerHeight="1sp"android:gravity="start"android:choiceMode="singleChoice" /></RelativeLayout></android.support.v4.widget.DrawerLayout>
Putting anything below your view would make it not appear when opened although it is visible in property. In your class you can swap the fragment as desired by calling the fragment manager and seleting a fragment at whatever list index is selected. I suggest use an internal listener and just call a method to pick the view and swap it. Like below:
Listener (Internal class):
classMainDrawerItemClickListenerimplementsAdapterView.OnItemClickListener{
@OverridepublicvoidonItemClick(AdapterView<?> adapter, View view, int position, long id ){
getView(position);
// close the drawers once selected
mDrawerLayout.closeDrawers();
}
}
That method will call this method in your main class:
// select the view publicvoidgetView( int position ){
Fragmentfrag=null;
switch( position ){
case0:
frag = newMyFragment();
break;
case1:
frag = newMyOtherFragment();
break;
default:
break;
}
if( frag != null ){
swapView( frag );
}
}
// swaps the fragmentspublicvoidswapView( Fragment frag ){
FragmentTransactionft= getSupportFragmentManager().beginTransaction();
ft.replace( R.id.frag_main_host, frag ).commit();
}
Hope it helps, I know this is an old question, but I am sure someone will have the same question.
Post a Comment for "View On Top Of Map Disappears While Using It With A Drawerlayout"