アクティビティに表示されるサポートマップの一部があります。ただし、フローティングアクションボタンは表示されません。私は非常に多くの方法を試みましたが、私はどこにもいません。フローティングアクションボタンが表示される
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/map_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"
tools:context=".views.activities.MainActivity"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_current_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_location_on_white_24dp"
app:elevation="4dp"
android:visibility="visible"
app:layout_anchorGravity="bottom|right|end"/>
val fragmentTransaction = mainAct.supportFragmentManager.beginTransaction()
val mapFragment = mainAct.supportFragmentManager.findFragmentById(R.id.map_fragment) as SupportMapFragment
fragmentTransaction.replace(R.id.main_container, mapFragment)
fragmentTransaction.addToBackStack("Map Fragment")
fragmentTransaction.commitAllowingStateLoss()
mapFragment.getMapAsync(this.mainAct)
すべてのヘルプは大幅に
EDIT評価されて:私のために働いたものを最後にを問題は、あなたがフラグメントを追加することである
val mapFragment = this.childFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
mapFragment.getMapAsync(this)
のように新しいフラグメントを追加でframeLayoutとXMLでフラグメントを置き換える代わりでframeLayoutのRelativeLayoutを使用してみてくださいので、 FABはその断片の下に横たわっています... –
あなたの返事をありがとう。これは私にとってはうまくいかなかった。 – SachchaDroid
FrameLayoutに2人の子供がいますか? –