预览片段的Anko layout

时间:2017-10-05 12:29:31

标签: anko

是否可以在片段的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?

谢谢
索伦

0 个答案:

没有答案