是否可以在片段的Anko布局的Android Studio中进行预览?我试图采用AnkoComponent方式,但我不能让它为片段工作。我有这个代码(剥离到必要):
class ProjectsFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
}
class FragmentUI : AnkoComponent {
private var projectsAdapter: ProjectsAdapter = ProjectsAdapter()
override fun createView(ui: AnkoContext) = with(ui) {
verticalLayout {
recyclerView {
lparams(width = matchParent, height = matchParent)
layoutManager = LinearLayoutManager(ctx)
adapter = projectsAdapter
}
}
}
}
}
但是如何在片段中使用AnkoComponent?
谢谢
索伦