How To Add Kotlin Anko Library


Anko is a Kotlin library which makes Android application development faster and easier. It makes your code clean and easy to read, and lets you forget about rough edges of the Android SDK for Java.
Anko consists of several parts:
  • Anko Commons: a lightweight library full of helpers for intents, dialogs, logging and so on;
  • Anko Layouts: a fast and type-safe way to write dynamic Android layouts;
  • Anko SQLite: a query DSL and parser collection for Android SQLite;
  • Anko Coroutines: utilities based on the kotlinx.coroutines library.

Anko Commons

Anko Commons is a "toolbox" for Kotlin Android developer. The library contains a lot of helpers for Android SDK, including, but not limited to:
  • Intents (wiki);
  • Dialogs and toasts (wiki);
  • Logging (wiki);
  • Resources and dimensions (wiki).

 


add to your project Level Gradle

ext.anko_version = '0.10.1'
 

add this to your app level gradle


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

Thats all now you are Ready to use Anko Library.

Features of Anko


 Toast

Without Anko

Toast.makeText(applicationContext,"Toast Text",Toast.LENGTH_SHORT).show()

With Anko

toast("Your Toast Text")

 

Start Activity

Without Anko

val intent = Intent(applicationContext,HomeActivity::class.java)
intent.putExtra("key","value")
startActivity(intent) 

With Anko

startActivity<HomeActivity>("key" to "value")

 

Reference : Anko

Comments

Popular posts from this blog

Kotlin Android Extensions

Android Easy Runtime Permissions with Dexter

Fast Android Networking Library Kotlin