Get preview of Anko layout for Fragment

Viewed 326

Is it possible to get a preview in Android Studio of Anko layout for a Fragment? I have tried to go the AnkoComponent way, but I can not get it to work for a fragment. I have this code (stripped down to essential):


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
                }
            }
        }

    }
}

But how do I use the AnkoComponent in a Fragment?

Thank you
Søren

0 Answers
Related