[Android] How to use Anko (constantly updated)

1. Introduction to Anko: http://blog.csdn.net/cjh_android/article/details/73121411

 

2. How to install:

Download the plugin:

Download the Anko plugin. 
Process: 
Click File -> setting -> plugin ->  write picture description here 
->  in the upper left corner of the studiowrite picture description here

 

配置gradle:https://github.com/Kotlin/anko

compile "org.jetbrains.anko:anko-commons:$anko_version"

 

Note: The value of ext.anko_version should be the same as the version of your Anko plugin

 

3. The pit about Anko: http://blog.csdn.net/cjh_android/article/details/73121411

 

4. Some usage of Anko:

1. Toast : Anko has included its own toast extension function, Anko provides some functions for CharSequenceand resource, and two different toast and longToast methods:

toast("Hello world!")
longToast(R.id.hello_world)

 

 5. How to preview:

Reference: https://blog.mindorks.com/how-to-preview-dsl-layouts-made-using-anko-layouts-f885c6bf67b3

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326107777&siteId=291194637