https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
anko
  • m

    mikesol

    02/07/2017, 2:13 PM
    Hey all! I’ve posted an issue on the anko github (https://github.com/Kotlin/anko/issues/311) that has a couple of my colleagues at Jongla scratching our heads. It looks like the type of black magic that is usually won’t even compile (missing method implementation) but is only caught at runtime. Perhaps there’s some sort of reflection error? The code in question is pretty simple. Alternatively, if anyone has a working implementation of
    ViewPager
    with
    FragmentPagerAdapter
    , I'll take it!
    l
    • 2
    • 4
  • a

    adeln

    02/28/2017, 12:16 PM
    remember that it’s not the instantiation that’s expensive, it’s measure + layout passes
    k
    • 2
    • 3
  • a

    adeln

    03/01/2017, 10:08 AM
    here’s my blog post on this issue https://meoyawn.tumblr.com/post/154221726637/anko-viewholders-and-applicative-lifting
    m
    • 2
    • 7
  • r

    redrield

    03/02/2017, 9:44 PM
    Cannot load project: com.intellij.ide.plugins.PluginManager$StartupAbortedException: com.intellij.diagnostic.PluginException: org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowManager [Plugin: org.jetbrains.kotlin.android.dsl]
    I get this error when trying to load projects in Android Studio after getting the Anko preview plugin
    l
    p
    • 3
    • 4
  • r

    redrield

    03/11/2017, 10:59 PM
    i.e. centerVertically() doesn't work for any children of the relative layout
    m
    • 2
    • 1
  • t

    tmseiler

    03/12/2017, 12:30 AM
    I'm pretty new to android development -- should I refer to the main android docs to learn about the UI controls, layouts, and views?
    m
    • 2
    • 1
  • d

    david.bilik

    03/13/2017, 7:23 PM
    Hello. Do you have any code styling conventions when you define layout with anko? With xml layouts the AS formatter will reorder attributes and you have attributes by definition at the top, but with anko dsl you can do whatever you want and the code can be really messy
    m
    • 2
    • 6
  • a

    adambl4

    03/17/2017, 12:44 PM
    databinding for rescue
    a
    • 2
    • 12
  • r

    ra1nmak3r

    03/17/2017, 9:37 PM
    Any news about anko preview in android studio 2.3+?
    ☝️ 5
    :trollface: 5
    y
    • 2
    • 1
  • e

    eygraber

    03/24/2017, 1:03 AM
    Is there any easy way to get Anko to use theming constructors on API 21+ The trick that is in place now with
    AnkoInternals.wrapContextIfNeeded
    doesn't always work (e.g. I pass
    Widget.AppCompat.Button.Borderless
    and instead of a flat button, I get a raised button with certain flat button attributes). I've worked around it for now by declaring my own version of
    ViewManager.ankoView
    , but it's annoying to either have a generic function (
    themedView
    ) or make a function for every
    View
    that I would want it for:
    inline fun <reified T : View> ViewManager.themedView(theme: Int, init: T.() -> Unit): T {
      val ctx = AnkoInternals.wrapContextIfNeeded(AnkoInternals.getContext(this), theme)
      val view = initiateView(ctx, T::class.java, theme)
      view.init()
      AnkoInternals.addView(this, view)
      return view
    }
    
    fun <T : View> initiateView(ctx: Context, viewClass: Class<T>, theme: Int): T {
      fun getConstructor() = viewClass.getConstructor(Context::class.java, AttributeSet::class.java, Int::class.java, Int::class.java)
      fun getConstructor2() = viewClass.getConstructor(Context::class.java)
      fun getConstructor3() = viewClass.getConstructor(Context::class.java, AttributeSet::class.java)
    
      return try {
        getConstructor().newInstance(ctx, null, 0, theme)
      } catch (e: NoSuchMethodException) {
        try {
          getConstructor2().newInstance(ctx)
        }
        catch (e: NoSuchMethodException) {
          try {
            getConstructor3().newInstance(ctx, null)
          }
          catch (e: NoSuchMethodException) {
            throw AnkoException("Can't initiate View of class ${viewClass.name}: can't find proper constructor")
          }
        }
      }
    }
    d
    • 2
    • 1
  • b

    blakelee

    03/26/2017, 6:21 AM
    How do you add a fragment to an activity? I'm trying to add caldroid. I tried using 'FragmentActivity().supportFragmentManager.beginTransaction().replace(R.id.calendar_view, CalendarFragment()).commit()' That's inside my onCreate method for my activity. It keeps giving me 'java.lang.IllegalStateException: Activity has been destroyed'
    m
    • 2
    • 2
  • r

    redrield

    03/28/2017, 12:02 AM
    Any way that I can achieve that?
    a
    • 2
    • 4
  • m

    Mark McCormick

    04/05/2017, 5:40 PM
    I am wondering if there is a way to set elevation = 0 for appBarLayout from API 16? For backwards compatibility I would like to use app:elevation (from support library) not android:elevation, not quite sure how to acomplish that. Thank you for your feedback
    a
    • 2
    • 3
  • g

    ghosalmartin

    04/07/2017, 10:04 AM
    does anyone know how doAsync can modify the UI without being on the UI threaD?
    m
    • 2
    • 1
  • m

    miha-x64

    04/11/2017, 1:04 PM
    Anko grew up since 0.9.1, try using
    +
    last version is
    0.10.0-beta-2
    😱 1
    👎 1
    l
    • 2
    • 3
  • j

    joe_androidsecurity

    04/16/2017, 3:19 PM
    I don't know how to solve this. I have an Anko layout, inside I have a button with onClick. In the onClick I want to change properties of other layouts, for example I have a verticalLayout whom background I want to change. Giving the verticalLayout a variable does not work. example code verticalLayout{ button.onClick{ // change the background of verticalLayout } }
    b
    • 2
    • 5
  • a

    anthonyeef

    04/19/2017, 2:12 AM
    try to use
    imageView
    with svg resource but svg is not showing. Anyone met the same issue?
    m
    • 2
    • 1
  • b

    blakelee

    04/19/2017, 9:46 PM
    Now there is another issue. I got it working except when I open the keyboard it collapses it. Here is a picture of it before: http://imgur.com/ghj0gnm and after http://imgur.com/UPfeo1H Edit: note to self, use layout_toRightOf instead of percentages
    l
    • 2
    • 1
  • a

    anthaugh

    04/24/2017, 7:57 AM
    has anyone succeeded in setting drawerLayout with navigationView header? If so, has anyone succeeded in showing drawer menu OVER the action bar? so far this is what i got:
    coordinatorLayout {
    			drawerLayout {
    				relativeLayout {
    					MY MAIN CONTENT
    				}
    				navigationView {
    					inflateHeaderView(R.layout.header) <- UGLY HACK, I CANNOT GET IT TO WORK ANY OTHER WAY
    				}
    			}
    
    			appBarLayout(R.style.AppTheme_AppBarOverlay) {
    				toolbar()
    			}
    	}
    but still it shows under the action bar (it's overlapped by it)
    m
    • 2
    • 16
  • b

    blakelee

    04/24/2017, 11:42 PM
    I'm trying to make a addTextChangedListener on an edit Text but it's being strange. I tried
    editText { addTextChangedListener (object : TextWatcher) {...}}
    There is no member onTextChanged
    j
    • 2
    • 2
  • m

    mikesol

    05/05/2017, 10:40 PM
    hey all! do any anko-ninjas know how to reduce the tabPadding of a tabLayout in anko? it is part of the app namespace in the XML, so maybe it’s not possible yet…
    m
    • 2
    • 3
  • m

    mikesol

    05/11/2017, 1:09 PM
    hey guys! do you know if anko 10 is backward compatible with anko 9? if not, what are the api breaking changes? i tried to update a project but saw that onClick for views is no longer there (or at least not where it used to be) but perhaps I messed up the update…?
    m
    e
    • 3
    • 5
  • d

    deviant

    05/12/2017, 7:34 PM
    is there a way to
    include
    AnkoComponent into another AnkoComponent? like we do it with xml layout
    y
    • 2
    • 3
  • b

    blakelee

    05/15/2017, 7:40 AM
    Does anyone know if there is an issue with setting an image for an image view? I'm trying to set it by uri and it's just a gray image :(
    m
    d
    z
    • 4
    • 11
  • d

    deviant

    05/16/2017, 7:11 PM
    guys, is it possible to apply xml style to the view?
    m
    • 2
    • 3
  • t

    than_

    05/19/2017, 1:18 PM
    Did anybody succeed to use anko with AS 3.0?
    y
    • 2
    • 2
  • a

    aakaashjois

    05/22/2017, 11:03 AM
    I have declared the
    frameLayout
    inside the onCreate method. I tried to create
    var enableCheckBox: CheckBox
    before declaring the frameLayout. But when i tried to access
    enableCheckBox
    in the rest of the onCreate method, it gave an error saying
    Variable "enableCheckBox" must be initialized
    c
    y
    • 3
    • 5
  • m

    miha-x64

    05/22/2017, 11:08 AM
    You want to use a view within a method, not within a class, right?
    var enableCheckBox: CheckBox? = null
    
    ... {
        enableCheckBox = checkBox { ... }
    }
    
    enableCheckBox!!....
    a
    • 2
    • 1
  • a

    anthaugh

    05/30/2017, 4:02 PM
    how can I apply bottomMargin recursively? I can set width and height like this
    applyRecursively { v: View ->
                    when (v) {
                        is EditText -> v.lparams(matchParent, wrapContent) { bottomMargin = dip(8) }
                         }
                    }
    but the margin isn't set. How should I code this?
    • 1
    • 1
  • a

    antonioleiva

    05/31/2017, 7:44 AM
    🤔 not sure about the difference between
    launch(UI)
    and
    async(UI)
    tbh, but worth trying
    l
    • 2
    • 1
Powered by Linen
Title
a

antonioleiva

05/31/2017, 7:44 AM
🤔 not sure about the difference between
launch(UI)
and
async(UI)
tbh, but worth trying
l

louiscad

06/03/2017, 11:29 PM
antonioleiva: launch returns
Unit
while
async
returns a
Deffered
on which you can call
await()
from a coroutine. I use
async
for methods in a Repository, so the UI code using it can await for completion without blocking UI thread in coroutines
View count: 3