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
compose
  • d

    dagomni

    05/28/2020, 11:57 AM
    Hi, after updating to dev12, WithConstraints that's inside of AdapterList keeps getting called which freezes the list during scroll, and then the app crashes Structure:
    AdapterList with Modifier.fillMaxSize()
    -Box with Modifier.wrapContentHeight() + Modifier.fillMaxWidth()
    --ConstraintLayout with Modifier.wrapContentHeight() + Modifier.fillMaxWidth() (I can also see non-stop constraints measure happening, it also gets logged)
    ---Box with Modifier.fillMaxWidth() + Modifier.aspectRatio(16 / 9f)
    ----WithConstraints
    -----Image (but it also happens with empty WithConstraints block)
    Crash:
    java.lang.IllegalStateException: Asking for measurement result of unmeasured layout modifier
            at androidx.ui.core.LayoutNodeWrapper.getMeasureResult(LayoutNodeWrapper.kt:63)
            at androidx.ui.core.LayoutNodeWrapper.getMeasuredSize(LayoutNodeWrapper.kt:53)
            at androidx.ui.core.Placeable.getWidth(Placeable.kt:40)
            at androidx.ui.core.LayoutNode.getWidth(LayoutNode.kt:373)
            at androidx.ui.foundation.ListState.composeAndMeasureNextItem-BTEqjtU(AdapterList.kt:237)
    m
    a
    • 3
    • 2
  • k

    Kazemihabib1996

    05/28/2020, 3:38 PM
    androidx.ui:ui-material-icons-extended
    removed in dev12?
    l
    • 2
    • 8
  • j

    Javier

    05/28/2020, 5:37 PM
    Navigation component integration is "coming soon"?
    👀 1
    h
    k
    • 3
    • 5
  • r

    Ricardo C.

    05/28/2020, 5:38 PM
    What's the reason behind moving towards Modifiers instead of having composables like Clickable and Toggleable? I find it weird having to declare the modifier param everywhere. Is it just because of nesting?
    h
    r
    +3
    • 6
    • 8
  • c

    camkadev

    05/28/2020, 6:25 PM
    drawRect
    doesn’t respect parents
    Padding
    starting from
    dev11
    version
    • 1
    • 1
  • d

    dagomni

    05/28/2020, 6:53 PM
    Values declared in
    group
    tags inside a vector drawable are not getting applied when I load the drawable using vectorResource. Should I extract them for each drawable and apply manually using DrawLayerModifier or is it something that's getting fixed soon? 🤔
    l
    n
    • 3
    • 10
  • m

    manueldidonna

    05/28/2020, 7:55 PM
    A bug with
    DropdownMenuItem
    on dev12. A ripple modifier is applied after the clickable one, so the onClick listener passed to the composable is never invoked
    l
    m
    • 3
    • 4
  • r

    romainguy

    05/28/2020, 10:39 PM
    We haven’t communicated anything yet 🙂
    ✔️ 2
    h
    a
    • 3
    • 2
  • c

    caelum19

    05/28/2020, 10:39 PM
    Trying dev12, getting this when I build:
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Could not determine the dependencies of task ':app:compileDebugKotlin'.
    > Could not resolve all dependencies for configuration ':app:kotlinCompilerPluginClasspath'.
       > Could not create task ':app:extractDeepLinksDebug'.
          > Cannot obtain value from provider of environment variable 'ANDROID_AAPT_IGNORE' at configuration time.
            Use a provider returned by 'forUseAtConfigurationTime()' instead.
    any pointers?
    h
    r
    +3
    • 6
    • 27
  • a

    allan.conda

    05/29/2020, 9:25 AM
    How can I achieve FrameLayout behavior from dev12? Seems
    Box
    behaves like
    Column
    now and
    Container
    is deprecated
    k
    • 2
    • 5
  • s

    Socheat KHAUV

    05/29/2020, 1:26 PM
    I read JetNews sample I saw this statement
    val (postsState, refreshPosts) = refreshableUiStateFrom(postsRepository::getPosts)
    I am a kotlin beginner, mabye could someone explain what mean ?
    t
    k
    • 3
    • 4
  • d

    dagomni

    05/29/2020, 1:35 PM
    I can't find any specifics in previous conversations - is there some kind of scroll listener for AdapterList? If not, it may be worth passing ListState in itemCallback lambda as well, so we can have access to it? 🙆‍♂️🏻
    a
    • 2
    • 1
  • z

    Zach Klippenstein (he/him) [MOD]

    05/30/2020, 1:24 AM
    With dev12, I’m getting this error in certain cases when subcompositions are involved. Has anyone else seen this with maybe
    AdapterList
    or
    WithConstraints
    ?
    Untitled
    l
    j
    • 3
    • 6
  • c

    carbaj0

    05/30/2020, 9:51 AM
    Hi! launchInComposition this is called only one time due to the remember, but what happens if I want to call it more than one time? For example:
    var text by state { "empty" }
    var result by state { "" }
    launchInComposition { result = getData(text) }
    FilledTextField(
        value = text,
        onValueChange = { text = it },
        label = { Text("Label") }
    )
    a
    • 2
    • 3
  • s

    Socheat KHAUV

    05/30/2020, 3:54 PM
    I want to have build a carousel of image. I create ModelList, and load item from RestAPI and add into it. at AdapterList, I wanted to add Image, but I could not find a way to have Image which load from network url. anyone could help ?
    a
    v
    +2
    • 5
    • 30
  • z

    Zach Klippenstein (he/him) [MOD]

    05/31/2020, 6:07 PM
    I’m still trying to come up with a reproducer, with dev12 i’m starting to get this compiler error:
    e: kotlin.UninitializedPropertyAccessException: Parent not initialized: org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl@e27c4d
    Posting eagerly just in case @Leland Richardson [G] already fixed this one too 😜
    l
    k
    • 3
    • 7
  • s

    Socheat KHAUV

    06/01/2020, 4:53 PM
    AdapterList to display item in Vertically ?
    v
    a
    a
    • 4
    • 7
  • r

    rophuine

    06/01/2020, 11:53 PM
    I'm struggling with the following error when attempting to update my state from a WebSocket callback:
    java.lang.IllegalStateException: Not in a frame
    at androidx.compose.frames.FramesKt.currentFrame(Frames.kt:180)
    W/System.err: at androidx.compose.frames.FramesKt.writable(Frames.kt:466)
    at androidx.compose.frames.FramesKt._writable(Frames.kt:462)
    I'm completely new to Android dev - most of my mobile dev before has been using xplat frameworks like Xamarin and React Native. I've managed to update to dev12. I suspect the problem is related to not being on the UI thread, but being so new to Android dev in general, and there not being many examples out there because Compose is so new, my Google-fu is failing me. Coroutines keep coming up but I can't quite work out the api. Can someone point me in the right direction?
    l
    v
    • 3
    • 6
  • j

    Javier

    06/02/2020, 7:57 AM
    message has been deleted
    g
    • 2
    • 4
  • l

    Lilly

    06/02/2020, 8:11 PM
    Hi most of the time break points in composable functions are not working. I'm using dev12. Does someone have an idea?
    h
    l
    a
    • 4
    • 8
  • h

    henrikhorbovyi

    06/02/2020, 11:10 PM
    There is no
    hint
    for TextField? 😮
    c
    • 2
    • 3
  • h

    henrikhorbovyi

    06/02/2020, 11:19 PM
    This error highlight does not stop
    l
    s
    +2
    • 5
    • 17
  • d

    Diego Marulanda

    06/03/2020, 2:19 AM
    Hi, could someone help me out by telling me, how I could create a declarative (without modifying xml) image slide in Jetpack Compose? I would appreciate it🙆‍♂️
    z
    • 2
    • 6
  • k

    Kazemihabib1996

    06/03/2020, 8:51 AM
    I've been reading https://android.googlesource.com/platform/frameworks/support/+/androidx-master-dev/ui/ui-layout/samples/src/main/java/androidx/ui/layout/samples/SizeModifierSample.kt And I found it a little weird,
    @Composable
    fun SimpleSizeModifier() {
        // The result is a 50.dp x 50.dp red box centered in a 100.dp x 100.dp space.
        // Note that although a previous modifier asked it to be 100.dp x 100.dp, this
        // will not be respected. They would be respected if preferredSize was used instead of size.
        Box(
            Modifier
                .size(100.dp, 100.dp)
                .size(50.dp, 50.dp),
            backgroundColor = Color.Red
        )
    }
    So it's another way of adding padding but instead of add a padding value we create some empty space and put a 50x50 box inside it. Am I right?
    m
    v
    • 3
    • 7
  • e

    Elena Boiko

    06/03/2020, 12:08 PM
    Hi 🙂 Does anyone know how we can change the width of ModalDrawerLayout?
    m
    • 2
    • 4
  • g

    Guy Bieber

    06/03/2020, 3:50 PM
    The world needs more magic. Put @Model back in.
    😄 6
    l
    • 2
    • 11
  • g

    Guy Bieber

    06/03/2020, 4:01 PM
    Is kotlin 1.4-M1 compatible with compose dev11?
    j
    • 2
    • 1
  • g

    Guy Bieber

    06/03/2020, 4:01 PM
    Also it would be nice if we could keep around the settings needed for older versions of compose.
    a
    • 2
    • 5
  • g

    Guy Bieber

    06/03/2020, 4:40 PM
    Which kotlinCompilerVersion works with compose dev11? I found this in the forms:
    kotlinCompilerVersion "1.3.70-dev-withExperimentalGoogleExtensions-20200424" //dev-11
    But I get errors like this:
    (24, 36): Class 'kotlin.Lazy' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler
    l
    • 2
    • 2
  • r

    romainguy

    06/03/2020, 9:44 PM
    You can do this by setting the theme of the activity in your manifest
    g
    v
    +2
    • 5
    • 29
Powered by Linen
Title
r

romainguy

06/03/2020, 9:44 PM
You can do this by setting the theme of the activity in your manifest
g

Guy Bieber

06/03/2020, 9:58 PM
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    tools:replace="android:theme"
    android:theme ="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <service android:name="com.nikolamotor.bluetoothle.BluetoothLeService" />
</application>
Not sure what to set it to.
v

Vinay Gaba

06/03/2020, 10:02 PM
basically this isn’t compose related necessarily and you would use the existing android style system to get this functionality. You would essentially create a custom theme and override this property
<item name="android:windowBackground">color_name</item>
Hopefully Romain was referring to this and not some compose magic that I was unaware about 😅
Which brings me to another question which potentially has been answered before - how do themes in compose & the existing way of creating themes in android interplay with each other? What’s the order of preference if I were to apply a theme to an activity in
AndroidManifest
and also use a different
MaterialTheme
inside the activity ? I’m guessing
MaterialTheme
would be what the user sees on the screen?
r

romainguy

06/03/2020, 10:07 PM
Compose doesn’t use the theme from the existing toolkit afaik
👍🏼 1
g

Guy Bieber

06/03/2020, 10:08 PM
Seems like we should be able to set something in the material theme here:
var splashView = SplashView()
setContent {
    MaterialTheme {
        splashView.view()
    }
}
I’m not sure what to set the MaterialTheme(colors =?) to for a dark theme
v

Vinay Gaba

06/03/2020, 10:13 PM
you could use the default
darkColorPalette()
👍 1
g

Guy Bieber

06/03/2020, 10:16 PM
I think it is this:
MaterialTheme(colors = darkColorPalette())
Just tried that and fail…
v

Vinay Gaba

06/03/2020, 10:24 PM
typically you would use logic like this to add support for dark mode -
val light = lightColorPalette()
val dark = darkColorPalette()

val colors = if (isSystemInDarkTheme()) { dark } else { light }
also could you elaborate on what exactly failed?
g

Guy Bieber

06/03/2020, 10:25 PM
white background on startup and black cursor.
expecting black background and white cursor
v

Vinay Gaba

06/03/2020, 10:26 PM
I’m guessing
SplashView
is a composable?
g

Guy Bieber

06/03/2020, 10:28 PM
yup
v

Vinay Gaba

06/03/2020, 10:28 PM
In order for it to take the appropriate colors from the theme, you need to either use the Material elements like Card or Surface, or explicitly set the color using the theme color. So something like
MaterialTheme.colors.surface
or
MaterialTheme.colors.primaryColor
when you use the Material elements, their default behavior is configured to use the colors from the theme automatically. So when you look at implementation of Card, you will see this
fun Card(
    modifier: Modifier = Modifier,
    shape: Shape = MaterialTheme.shapes.medium,
    color: Color = MaterialTheme.colors.surface,
    contentColor: Color = contentColorFor(color),
    border: Border? = null,
    elevation: Dp = 1.dp,
    content: @Composable () -> Unit
) {
Notice how it automatically uses the
MaterialTheme.colors.surface
by default when you don’t give it a color
if you aren’t using the Material elements, you need to give it a similar behavior for it to pick up the colors from the theme. Maybe you were already doing this but just didn’t share it in the code snippets
g

Guy Bieber

06/03/2020, 10:31 PM
My splash screen comes up with the correct colors, however briefly before that a white screen is displayed. Also the cursor shows up as black by default. I am trying to change that.
a

Adam Powell

06/03/2020, 10:51 PM
If you ctrl (or cmd) click on the
@style/AppTheme.NoActionBar
theme declaration from the activity element in your manifest, it'll take you over to the resource xml file that holds that theme in your app. (probably
res/values/styles.xml
if you're using the default project template)
That xml theme definition is what Android reads and shows to the user before your app code starts running
it'll have a parent declaration that probably looks something like
@style/Theme.AppCompat.Light.NoActionBar
- get rid of the .
Light
part in there.
this all happens at a pretty low-level within Android, since this window background is what Android shows as it's still loading your apk's code to show responsiveness to the user launching the app. this usually takes a couple hundred milliseconds from a cold process start.
g

Guy Bieber

06/04/2020, 3:06 AM
Still get the white flash with this
android:theme="@style/AppTheme.NoActionBar">
Might just be noticeable because I am loading from a usb connection instead of installed app.
r

romainguy

06/04/2020, 5:47 AM
How's that theme defined?
a

Adrian Blanco

06/04/2020, 7:34 AM
When I did this, defining windowBackground in the main theme was enough to solve the white screen on startup. However I also had to define day / night color resources so it would pick the correct colors based on current mode
View count: 2