android - Map overflows onto next tab in ActionBar -


i have action bar set , map displaying on first tab. have disabled scrolling on first tab user can navigate on map. when user presses second tab, there big black square in shape of map , little sliver of previous map overflowing.

here pictures. had take 2nd 1 manually because every time took screen shot, black went away reason.

enter image description here enter image description here

code first tab

public static class map extends fragment {     mapview mapview;     googlemap map;      @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {         view v = inflater.inflate(r.layout.maptab, container, false);          // gets mapview xml layout , creates         mapview = (mapview) v.findviewbyid(r.id.mapview);         mapview.oncreate(savedinstancestate);          // gets googlemap mapview , initialization stuff         map = mapview.getmap();         //map.getuisettings().setmylocationbuttonenabled(false);         //map.setmylocationenabled(true);         map.addmarker(new markeroptions().position(new latlng(50.167003,19.383262)));           // needs call mapsinitializer before doing cameraupdatefactory calls         try {             mapsinitializer.initialize(this.getactivity());         } catch (googleplayservicesnotavailableexception e) {             e.printstacktrace();         }          // updates location , zoom of mapview         //cameraupdate cameraupdate = cameraupdatefactory.newlatlngzoom(new latlng(43.1, -87.9), 10);         //map.animatecamera(cameraupdate);          return v;     }      @override     public void onresume() {         mapview.onresume();         super.onresume();     }      @override     public void ondestroy() {         super.ondestroy();         mapview.ondestroy();     }      @override     public void onlowmemory() {         super.onlowmemory();         mapview.onlowmemory();     } } 

xml file maptab.xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout 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"     android:orientation="vertical">      <com.google.android.gms.maps.mapview         android:id="@+id/mapview"         android:layout_width="match_parent"         android:layout_height="match_parent" >     </com.google.android.gms.maps.mapview>  </linearlayout> 

hack solution please let me know if can think of other way solve this

    @override     public void ontabselected(actionbar.tab tab, fragmenttransaction fragmenttransaction) {         // when given tab selected, switch corresponding page in viewpager.         if(tab.getposition() == 1){ //if tab next map tab, set map invisible             mapview.setvisibility(view.invisible);         } else if(tab.getposition() == 0 && mapview != null){ //if map tab clicked , map not null, set map visible             mapview.setvisibility(view.visible);         }         mviewpager.setcurrentitem(tab.getposition());      } 


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -