答案 0 :(得分:0)
当前,无法直接从anko创建<fragment>
标签。
您应该创建NavHostFragment并手动添加它:
val finalHost = NavHostFragment.create(R.navigation.example_graph)
linearLayout {
id = 1
supportFragmentManager.beginTransaction()
.replace(1, finalHost)
.setPrimaryNavigationFragment(finalHost) // this is the equivalent to app:defaultNavHost="true"
.commit()
}