Kotlin / anko

Pleasant Android application development
Apache License 2.0
15.88k stars 1.29k forks source link

Where can I find documentation? #429

Open jadennnn opened 7 years ago

jadennnn commented 7 years ago

I'm frankly surprised that the closest there is to documentation is the wiki pages - I've got to be somehow missing something obvious. I'm looking for documentation on all publicly exposed API & the DSL. The README & wiki are nice introductions for this library and it definitely sold me on it. But I cannot track down anything documenting the DSL/API.

For example - which specific views does the DSL support? In the "Basics" section of the wiki, the last paragraph says that "blocks exist for almost every View"...which of the Android Views are supported? Apparently BottomNavigationView is not one of them.

nvlled commented 7 years ago

The document is indeed lacking, and you have to do a bit of source digging to find what you are looking for. The list of views available can be found in Views.kt files such as https://github.com/Kotlin/anko/blob/master/anko/library/generated/sdk25/src/Views.kt

The BottomNavigationView seems to be defined here (bottomNavigationView) https://github.com/Kotlin/anko/blob/master/anko/library/generated/design/src/Views.kt The package of that file is org.jetbrains.anko.design, so:

import org.jetbrains.anko.design.*

verticalLayout {
    bottomNavigationView()
}

... still does not work unless you add the dependencies for support libraries in your build.gradle, as described here https://github.com/Kotlin/anko/blob/master/README.md#gradle-based-project

// Design
compile "org.jetbrains.anko:anko-design:$anko_version"
// Include this if you haven't done already
compile 'com.android.support:design:25.4.0'

If you're like me, the above steps probably still would not work if your sdk versions doesn't match, which I fixed by setting my compileSdkVersion to 'android-25'. But to be fair this is a problem with the android project configuration itself.

jadennnn commented 7 years ago

Thank so much you for your help!

Unfortunately, it's against my personal & professional policy to use undocumented libraries, as nice as they might be 🙁 . I'll be excited to return to this library when it's documented!

Anti-Alias commented 6 years ago

I know this is late, but I felt like joining the party.

I guess you can use anko if you're not afraid of IDE dependence. You'll just have to inspect fields/methods with autocomplete (Yay?)

You could also clone releases and generate documentation with dokka manually. The anko repo has dokka-android included in its build.gradle file, so it should be as easy as a

git clone https://github.com/Kotlin/anko.git
cd anko
./gradlew dokka

Not ideal, but hey!

jasonpp commented 5 years ago

You can exactly go to website:https://www.raywenderlich.com/5193-anko-commons-tutorial. I guess the common usage for this frame is enough.