android - Inflating a View inside a Layout after adding a MapFragment to the same layout weird behavior -
i have following parent layout activity:
<?xml version="1.0" encoding="utf-8"?> <viewpager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" />
i have following layout fragment
goes viewpager
:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <framelayout android:id="@+id/maplayout" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> </relativelayout> </linearlayout>
at runtime framelayout
gets populated on oncreateview()
method of fragment this:
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { super.oncreate(savedinstancestate); ... viewgroup mapview = (viewgroup) inflater.inflate(r.layout.frament_mood_map, container, false); if(savedinstancestate == null) { fragment mapfragment = new supportmapfragment(); fragmenttransaction transaction = getchildfragmentmanager().begintransaction(); //adding map fragment framelayout. transaction.add(r.id.maplayout, mapfragment, "map").commit(); } //adding mood panel. viewgroup maplayout = (viewgroup) mapview.findviewbyid(r.id.maplayout); maplayout.addview(inflater.inflate(r.layout.mood_panel_layout, null)); ... return mapview; }
the expected behavior since container gets populated fragment
, view
framelayout
, former gets added first container, , later on top of map, want show map little panel on top has buttons, cannot define fragment
inside xml because (citing docs, , yes i've tried it):
note: cannot inflate layout fragment when layout includes . nested fragments supported when added fragment dynamically
what doing wrong? how can workaround this?
after hours of fiddling , trying find workaround found out there's updated mapview
on google maps android api v2, having same issue need nest within viewpager
page fragment mapfragment
use mapview
.
i found mapview
in following question: should use mapview or mapfragment
Comments
Post a Comment