Preview Anko DSL views

818 views Asked by At

I'm looking for a way to preview the rendering of an Anko view DSL in Android Studio. I've searched a lot and found only some deprecated or not working Android studio plugins. Is there a trick or something to make it works ? The Anko Support plugins doesn't work...

1

There are 1 answers

0
Rashi Karanpuria On

I use Anko support plugins to preview DSL layouts all the time. There may be a few reasons why it may not work in your case:

  1. Your layout should be defined in an external class that implements AnkoComponent interface.
  2. Try rebuilding your project if the layout does not render properly. The preview works after the project is rebuilt.
  3. Try refreshing the layout if that might solve your issue.
  4. Make sure your Anko dependencies are latest and Android Studio 3+. If you can share more info like the versions of your plugins and your code, maybe I can help pinpoint the exact issue. Meanwhile here is an article that can surely help you out: https://blog.mindorks.com/how-to-preview-dsl-layouts-made-using-anko-layouts-f885c6bf67b3