我尝试从 SaveRouteFragment
前往 RecordRouteFragment
。结果是两个片段彼此重叠。
我在互联网上搜索并没有找到我的问题的答案,尽管有些人有类似的重叠问题。
fragment_record_route.xml:
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".features.routerecording.ui.RecordRouteFragment">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/cl_frg_container">
// content
</FrameLayout>
</LinearLayout>
fragment_save_route.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
// content
</androidx.constraintlayout.widget.ConstraintLayout>
来自 RecordRouteFragment.kt 的 onClickListener
private val btStopRecordOnClick = View.OnClickListener() {
stopLocationService()
viewModel.markRouteAsNotCurrent()
childFragmentManager.commit {
replace<SaveRouteFragment>(binding.clFrgContainer.id) //when I replace that with usual R.id.cl_frg_container - nothing changes
setReorderingAllowed(true)
addToBackStack("Save a route") // name can be null
}
}
我做错了什么?
答案 0 :(得分:0)
我不得不将 SaveRouteFragment 的背景颜色更改为例如白色。