Technology moves fast! ⚑ Don't get left behind.🚢 Subscribe to our mailing list to keep up with latest and greatest in open source projects! πŸ†


Subscribe to our mailing list

anko

Pleasant Android application development

Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star half bd79095782ee4930099175e5ce7f4c89fa3ddabcd56fffcc7c74f6f2a2d46b27 (1 ratings)
Rated 4.5 out of 5
Subscribe to updates I use anko


Statistics on anko

Number of watchers on Github 10210
Number of open issues 150
Average time to close an issue about 1 month
Main language Kotlin
Average time to merge a PR 16 days
Open pull requests 37+
Closed pull requests 27+
Last commit about 1 year ago
Repo Created over 4 years ago
Repo Last Updated about 1 year ago
Size 14.6 MB
Organization / Authorkotlin
Latest Releasev0.10.4
Contributors18
Page Updated
Do you use anko? Leave a review!
View open issues (150)
View anko activity
View TODOs for anko (2)
View on github
Fresh, new opensource launches πŸš€πŸš€πŸš€
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating anko for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)
What people are saying about anko Leave a review
its give me an ability to write more flexible dynamic views ...

official JetBrains project Download TeamCity (simple build status) GitHub license

Anko logo

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).

Anko Layouts (wiki)

Anko Layouts is a DSL for writing dynamic Android layouts. Here is a simple UI written with Anko DSL:

verticalLayout {
    val name = editText()
    button("Say Hello") {
        onClick { toast("Hello, ${name.text}!") }
    }
}

The code above creates a button inside a LinearLayout and attaches an OnClickListener to that button. Moreover, onClick accepts a suspend lambda, so you can write your asynchronous code right inside the listener!

Note that this is the complete layout code. No XML is required!

Anko has a DSL for ConstraintLayout since v0.10.4

Hello world

There is also a plugin for Android Studio that supports previewing Anko DSL layouts.

Anko SQLite (wiki)

Have you ever been tired of parsing SQLite query results using Android cursors? Anko SQLite provides lots of helpers to simplify working with SQLite databases.

For example, here is how you can fetch the list of users with a particular name:

fun getUsers(db: ManagedSQLiteOpenHelper): List<User> = db.use {
    db.select("Users")
            .whereSimple("family_name = ?", "John")
            .doExec()
            .parseList(UserParser)
}

Anko Coroutines (wiki)

Anko Coroutines is based on the kotlinx.coroutines library and provides:

  • bg() function that executes your code in a common pool.
  • asReference() function which creates a weak reference wrapper. By default, a coroutine holds references to captured objects until it is finished or canceled. If your asynchronous framework does not support cancellation, the values you use inside the asynchonous block can be leaked. asReference() protects you from this.

Using Anko

Gradle-based project

Anko has a meta-dependency which plugs in all available features (including Commons, Layouts, SQLite) into your project at once:

dependencies {
    compile "org.jetbrains.anko:anko:$anko_version"
}

Make sure that you have the $anko_version settled in your gradle file at the project level:

ext.anko_version='0.10.4'

If you only need some of the features, you can reference any of Anko's parts:

dependencies {
    // Anko Commons
    compile "org.jetbrains.anko:anko-commons:$anko_version"

    // Anko Layouts
    compile "org.jetbrains.anko:anko-sdk25:$anko_version" // sdk15, sdk19, sdk21, sdk23 are also available
    compile "org.jetbrains.anko:anko-appcompat-v7:$anko_version"

    // Coroutine listeners for Anko Layouts
    compile "org.jetbrains.anko:anko-sdk25-coroutines:$anko_version"
    compile "org.jetbrains.anko:anko-appcompat-v7-coroutines:$anko_version"

    // Anko SQLite
    compile "org.jetbrains.anko:anko-sqlite:$anko_version"
}

There are also a number of artifacts for the Android support libraries:

dependencies {
    // Appcompat-v7 (only Anko Commons)
    compile "org.jetbrains.anko:anko-appcompat-v7-commons:$anko_version"

    // Appcompat-v7 (Anko Layouts)
    compile "org.jetbrains.anko:anko-appcompat-v7:$anko_version"
    compile "org.jetbrains.anko:anko-coroutines:$anko_version"

    // CardView-v7
    compile "org.jetbrains.anko:anko-cardview-v7:$anko_version"

    // Design
    compile "org.jetbrains.anko:anko-design:$anko_version"
    compile "org.jetbrains.anko:anko-design-coroutines:$anko_version"

    // GridLayout-v7
    compile "org.jetbrains.anko:anko-gridlayout-v7:$anko_version"

    // Percent
    compile "org.jetbrains.anko:anko-percent:$anko_version"

    // RecyclerView-v7
    compile "org.jetbrains.anko:anko-recyclerview-v7:$anko_version"
    compile "org.jetbrains.anko:anko-recyclerview-v7-coroutines:$anko_version"

    // Support-v4 (only Anko Commons)
    compile "org.jetbrains.anko:anko-support-v4-commons:$anko_version"

    // Support-v4 (Anko Layouts)
    compile "org.jetbrains.anko:anko-support-v4:$anko_version"

    // ConstraintLayout
    compile "org.jetbrains.anko:anko-constraint-layout:$anko_version"
}

There is an example project showing how to include Anko library into your Android Gradle project.

IntelliJ IDEA project

If your project is not based on Gradle, just attach the required JARs from the jcenter repository as the library dependencies and that's it.

Contributing

The best way to submit a patch is to send us a pull request. Before submitting the pull request, make sure all existing tests are passing, and add the new test if it is required.

If you want to add new functionality, please file a new proposal issue first to make sure that it is not in progress already. If you have any questions, feel free to create a question issue.

Instructions for building Anko are available in the Wiki.

anko open issues Ask a question     (View All Issues)
  • over 2 years Workaround to use RelativeLayout positioning without ids
  • over 2 years Using lparams in CardView's direct children causes ClassCastException
  • over 2 years tintedImageView support
  • over 2 years Use DSL for custom components
  • over 2 years Swap default view implementation with Anko?
  • over 2 years ClassCastException in TextInputLayout
  • over 2 years Add ability to use AnkoLogger as an instance
  • over 2 years Rename `forEachWithIndex` and others to `forEach0`
  • over 2 years Create SqliteTable example has faulty syntax
  • over 2 years preview plug not support for kotlin-1.0.4-release
  • over 2 years Can't set app:layout_columnWeight from DSL
  • over 2 years org.jetbrains.anko.AnkoException: 'android.widget.TextView.enabled' property does not have a getter
  • over 2 years `style` method mentioned in README is deprecated
  • over 2 years java.lang.NoSuchMethodError: android.view.ContextThemeWrapper.getThemeResId
  • over 2 years IllegalArgumentException: Stacks have different current sizes [0] and [1] when building with ProGuard optimizations
  • almost 3 years 'labelFor' that accepts View
  • almost 3 years floatActionButton(theme:Int) not working
  • almost 3 years Not support for menus creation
  • almost 3 years imageButton DSL compatibility broken
  • almost 3 years 'forEach',... for SparseArray
  • almost 3 years Cleaner dip usage
  • almost 3 years FOREIGN_KEY usage in SQLite createTable DSL
  • almost 3 years alert builder is private
  • almost 3 years intentFor() should allow null values
  • almost 3 years Support ConstraintLayout in Anko
  • almost 3 years Proguard Warning: org.jetbrains.anko.internals.AnkoInternals: can't find referenced method 'int getThemeResId()' in library class android.view.ContextThemeWrapper
  • almost 3 years android.support.design.widget.TextInputEditText
  • almost 3 years Proposal: Toast like helpers for Snackbar
  • almost 3 years Anko DSL Preview for Android Studio 2.2
  • almost 3 years Anko 0.9 beta1, DSL Preview Plugin
anko open pull requests (View All Pulls)
  • Few corrections for SQLite static module
  • Attribute resolve for colors, dimensions and "raw" attributes
  • Explain the various Anko libs in README. Fix #84
  • AndroidJarFileCollector: Overwrite existing jars
  • TextView.enabled has a getter
  • Added send sms helper
  • Allow the database to be pluggable for query builders
  • Add PREVIEW.md page #238
  • update gson version
  • Update SQLite package version in docs
  • Add labelFor extension that accepts View as parameter
  • Add SparseArrays forEach extensions
  • Add extensions for View#backgroundColorResource and TextView#textColorResource
  • fix for #249 broken link to jarjar library
  • WIP: Add 3rd view constructor to factories *NEEDS HELP*
  • Update Async.kt
  • Fix typos in Gradle dependency versions
  • Update doc on rename of where? to whereSimple
  • added sample code for onCreate and onUpgrade for DatabaseOpenHelper
  • Fix compilation error in example code for creating tables
  • Support BottomNavigationView
  • fixed spelling mistake
  • Uses valid jcenter repos in readme
  • Added textAppearance property and horizontalLayout
  • Added extension methods with no params for TextView
  • Menus
  • childrenRecursiveSequence: fix NoSuchElementException being thrown when hasNext() returned true
  • Allow nullable values in `bundleOf` and `withArguments`
  • Constraint layout
  • re-Added "findviewbyid", I had to recreate this function on my app on…
  • Add support to foreign key constraint actions
  • Update support fragment helpers
  • Add - Snackbar extensions for Activity, Fragment and View
  • Added doBeforeSdk function
  • Add joins to select query
  • Fix SparseArrays package
  • Update README.md
anko questions on Stackoverflow (View All Questions)
  • Anko: inner scope of apply, confusing property resolution
  • How to use Anko DSL inside a Fragment?
  • Anko 0.8 - unresolved lparams reference
  • How to reference other views in Anko DSL?
  • Convert MainActivity with actionbar/toolbar and floatingaction button to Anko
  • What's the best way to take a picture and display the result using Kotlin Anko?
  • How Can I Mask A Password With Anko?
  • Horizontal LinearLayout in Anko
anko list of languages used
anko latest release notes
v0.10.4 Anko 0.10.4

What's new

v0.10.3 Anko 0.10.3

Bugfixes

  • Anko support plugin compatibility with Kotlin 1.1.60+
  • Fix Xml to Dsl converter (#370)
  • lparams for CollapsingToolbarLayout, now returns correct LayoutParams (#275, #269)
  • Context.clipboardManager now returns new ClipboardManager instead of deprecated one (#180)
  • Generate layout wrapper for CardView (#269, #357)
  • Fix ClassParser's Boolean parser when type is Long (#464)

Breaking Changes

  • Removed Dsl for classes from android.support.design.internal.* as they shouldn't be used outside of support library

Other Changes

  • TextInputEditText added to anko-design (#205)
  • Anko commons dialog extensions now accept CharSequence instead of String (#422)
  • Add start and end rules to RelativeLayout.LayoutParams extensions (#497)
  • Add allCaps and ems properties to TextView (#459)
  • Add snackbar helpers with indefinite duration (#454)
  • Allow nullable values in createIntent and startActivity (#465)
  • Add extensions for View::backgroundColorResource and TextView::textColorResource (#254)
  • Return ComponentName from startService methods (#435)
  • Allow alerts to be cancelable (#405)
  • Add intent helpers for stopping services (#509)
  • Return toast object in toast helper functions (#512)
v0.10.2 Anko 0.10.2

Changes

  • Fixed Anko Support IDE plugin compatibility with Android Studio 3.0 RC1
  • Fragment.indeterminateProgressDialog now shows indeterminate progress dialog instead of classic #487
  • Added methods for creating and dropping a index for SQLiteDatabase #472
Other projects in Kotlin