https://kotlinlang.org logo
Docs
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
  • z

    Zach Klippenstein (he/him) [MOD]

    10/03/2020, 5:44 AM
    I’m seeing some behavior that I think might be a bug. It seems like `LayoutModifier`s are only being calculated when they’re first applied to a node, and any changes in subsequent compositions don’t actually update the layout. E.g. I’m trying to move a composable around by passing a custom
    Alignment
    implementation that just takes a fraction and aligns to that fraction of the parent. The initial alignment is calculated correctly, but when the fraction changes in subsequent compositions, the composable’s position doesn’t change. Will file soon.
    👍 2
    m
    • 2
    • 4
  • v

    Vinay Gaba

    10/03/2020, 6:32 AM
    Noticing some weird behavior where my UI tests pass on the emulator but fail on the device. I’m doing a super basic check -
    composeTestRule.onNodeWithText("Title").assertExists()
    a
    • 2
    • 4
  • k

    Kyant

    10/03/2020, 6:35 AM
    Crashed when using
    webContext.goBack()
    to handle back press in WebView.
    java.lang.IllegalStateException: KeyEvent can't be processed because this key input node is not active.
    at androidx.compose.ui.input.key.KeyInputModifier.processKeyInput(KeyInputModifier.kt:62)
    at androidx.compose.ui.platform.AndroidComposeView.sendKeyEvent(AndroidComposeView.kt:196)
    at androidx.compose.ui.platform.AndroidComposeView.dispatchKeyEvent(AndroidComposeView.kt:200)
    Is something wrong? I remember it won't crash before.
    d
    • 2
    • 2
  • d

    Davide Giuseppe Farella

    10/03/2020, 6:57 AM
    What’s the replacement for
    Modifier.align
    on alpha 4?
    👍 1
    ✅ 1
    z
    • 2
    • 7
  • m

    Michal Harakal

    10/03/2020, 6:20 PM
    What are simple samples showing the power of kotlin compiler plugin for jetpack compose, enabling language constructs not possible with standard kotlin language? I am preparing a talk about kotlin compiler plugins and jetpack compose comes as the first on my mind …
    s
    • 2
    • 2
  • p

    pardom

    10/04/2020, 12:38 AM
    Is there an example of animating away a list item? I’m using SwipeToDismiss and it animates the previous item in the list when recovering. Here’s the relevant code:
    Untitled.kt
    g
    j
    • 3
    • 6
  • p

    pavi2410

    10/04/2020, 8:16 AM
    In other words, is it even possible to reset the applied Modifiers? Like in CSS? It can be useful to tweak existing composables components
    ➕ 1
    z
    • 2
    • 1
  • n

    nlindberg

    10/04/2020, 11:04 AM
    Anyone tried getting the following error when using ScrollableColumn composable: (version: ‘1.0.0-alpha04’)
    java.lang.IllegalStateException: Reading a state that was created after the snapshot was taken or in a snapshot that has not yet been applied
    ➕ 5
    r
    c
    • 3
    • 5
  • n

    Nat Strangerweather

    10/04/2020, 2:35 PM
    Hi, what am I doing wrong here? I am trying to use the SpaceBetween arrangement but both Strings are stuck on the left of my screen:
    @Composable
    fun PriorityOptions() {
        ScrollableColumn(
            modifier = Modifier.fillMaxWidth()
                .fillMaxHeight()
                .padding(start = 20.dp, end = 20.dp),
    
            ) {
            Spacer(Modifier.preferredHeight(50.dp))
            Text(text = "Priority Options", style = typography.h1)
            Spacer(Modifier.preferredHeight(50.dp))
            Row(horizontalArrangement = Arrangement.SpaceBetween) {
                Text("Start")
                Text("End")
            }
        }
    f
    s
    • 3
    • 3
  • z

    zoha131

    10/04/2020, 4:28 PM
    How can I detect if software keyboard is visible in the screen or not?
    a
    s
    • 3
    • 6
  • t

    Thiago

    10/04/2020, 8:35 PM
    Compose Text Team there is a wrong copy/paste here :
    j
    n
    • 3
    • 2
  • t

    Thiago

    10/04/2020, 8:47 PM
    Is there a console logger (like Logcat) to Compose Preview? I would like to log/print some Compose behaviors without deploy to a device.
    👀 4
    • 1
    • 1
  • d

    Denis Sakhapov

    10/05/2020, 3:43 AM
    Documentation is broken? All the examples there show
    //Unresolved: androidx.compose. …
    https://developer.android.com/reference/kotlin/androidx/compose/animation/package-summary#animate
    ➕ 14
    e
    n
    • 3
    • 2
  • s

    Sam

    10/05/2020, 7:51 AM
    Can someone from the core team share insight on the reason for the name change? Coming from SwiftUI, Stack is quite familiar nomenclature!
    👍 1
    b
    m
    +4
    • 7
    • 6
  • a

    Archie

    10/05/2020, 11:09 AM
    Text
    composable when not placed in a
    Surface
    seem to not apply
    Material Theme
    correctly. So when I do:
    Column {
        Text()  // This text color is black in both light and dark theme
    }
    It seems that
    ContentAmbientColor
    is not properly set for
    onBackgroundColor
    (composables not part of a surface). Its really hard to trace what exactly is the problem though, as routing to sources in the IDE is currently broken.
    l
    • 2
    • 2
  • p

    Prashant Priyadarshi

    10/05/2020, 11:37 AM
    How to make scrollbars in a ScrollableRow always visible. I am looking for something like android:fadeScrollbars="false".
    j
    k
    • 3
    • 5
  • z

    zoha131

    10/05/2020, 12:02 PM
    If a parent compose collect a
    Flow
    from
    ViewModel
    as
    state
    and it’s multiple children also collect the same flow as state then would it hamper the performance? I have TextFields in different layer. So passing state would make the code messy. Thats why wanted to collect the same flow from multiple Composables.
    z
    • 2
    • 2
  • p

    Prashant Priyadarshi

    10/05/2020, 12:51 PM
    I am trying to move to compose 1.0.0-alpha04 and I have updated the new compiler dependency androidx.compose.compiler:compiler:1.0.0-alpha04 but still I am getting the below error, any idea why?
    Execution failed for task ':app:prepareDebugKotlinCompileTask'.
    > Could not resolve all files for configuration ':app:kotlin-extension'.
    > Could not find androidx.compose:compose-compiler:1.0.0-alpha04.
    z
    • 2
    • 2
  • p

    ppvi

    10/05/2020, 12:54 PM
    you need to update AGP to alpha13
    👍 1
    p
    • 2
    • 1
  • d

    Daniele B

    10/05/2020, 1:14 PM
    I was reading that in 1.0.0-alpha04, the
    LazyColumnFor
    issue about remembering the scrolling position was fixed. But I just checked and it’s not, at least not automatically. My use case is very simple: a list of elements; click on one element to display the detail page; going back to the list; the position is reset to the top, and not kept So, do we need to explicitly set that it should be remembered? And How? I mean that would be strange, as in the normal Android view system, the list scroll position is remebered when you go back to the list screen.
    a
    z
    s
    • 4
    • 17
  • a

    allan.conda

    10/05/2020, 1:57 PM
    Does the LazyItemScope work like a Column? It seems so. Wondering if I need to wrap content of item in a Column or call
    item{}
    multiple times, since it says
    Adds a single item to the scope.
    in the doc.
    LazyColumn {
       item { Text("Title") }
       item { Header() }
       items(items) { ... }
    }
    // or
    LazyColumn {
       item {
          Text("Title)
          Header()
       } 
       items { ... } 
    }
    a
    • 2
    • 5
  • r

    Robert Menke

    10/05/2020, 3:10 PM
    I’ve been stuck on this error for like 8 hours. I have a simple component
    @Composable
    fun EmailTextField() {
        val viewModel = viewModel<AuthenticationViewModel>()
        val text: String by viewModel.email.observeAsState("")
        TextField(
            value = text,
            onValueChange = viewModel::setEmail,
            label = { Text(text = "What's your email address?") },
            placeholder = { Text(text = "<mailto:jane.doe@gmail.com|jane.doe@gmail.com>") },
            keyboardType = KeyboardType.Email,
            modifier = frameFillWidth(60.dp)
        )
    }
    The context it’s called in is this:
    @Composable
    fun SignInEmailView() {
        SingleInputLayout(
            onBackClicked = {},
            onNextClicked = {},
            children = {
                EmailTextField()
            }
        )
    }
    and I get the error:
    e: java.lang.IllegalArgumentException: Unbound type parameters are forbidden: [Unbound private symbol org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl@124a0920, Unbound private symbol org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl@6e295b2d]
    I’ve been able to isolate this error to the
    EmailTextField
    view and when I comment it out the error goes away. I’ve tried reproducing in a sample project but have been unable to do so. Does anything in the example I’ve provided seem off? compose: 1.0.0-alpha04 kotlin: 1.4.10
    a
    d
    • 3
    • 12
  • r

    Robert Menke

    10/05/2020, 6:10 PM
    Is the EAP version of kotlin (1.4.20-M1) compatible with alpha04?
    z
    a
    +2
    • 5
    • 11
  • s

    Sergey Y.

    10/05/2020, 10:30 PM
    How to align two Text composables by a baseline?
    v
    p
    • 3
    • 5
  • b

    Brett Best

    10/06/2020, 3:51 AM
    Is it possible to get a compose dialog to appear fullscreen without padding?
    f
    n
    • 3
    • 2
  • j

    Jamie Craane

    10/06/2020, 6:40 AM
    I am starting to experiment with drag and drop in compose. A view is made draggable by implementing the dragGestureListener and then modifying the x and y offset to the view can be dragged across the screen (is this the correct way). There are several views on which the view can be dragged-on. See the screenshot below. What is the preferred way of detecting the target view the view is dropped on? I have included some sample code.
    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
    
            var deleted by mutableStateOf(false)
            val x = mutableStateOf(0f)
            val y = mutableStateOf(0f)
    
            val colors = listOf(Color.Green, Color.Gray, Color.Blue)
    
            setContent {
                DragAndDropTestTheme {
                    Surface(color = MaterialTheme.colors.background) {
                        Column() {
    //                        This row contains potential drop targets
                            Row(
                                modifier = Modifier
                                    .height(150.dp)
                                    .fillMaxWidth()) {
                                colors.map {
                                    Box(
                                        modifier = Modifier.background(it).weight(1f).fillMaxHeight()
                                    )
                                }
                            }
                            Box(
                                modifier = Modifier.fillMaxWidth().fillMaxHeight()
                                    .background(Color.Magenta)
                            ) {
                                if (!deleted) {
                                    Box(
                                        modifier = Modifier
                                            .offsetPx(x, y)
                                            .background(Color.Cyan).width(75.dp).height(75.dp)
                                            .dragGestureFilter(object : DragObserver {
                                                override fun onDrag(dragDistance: Offset): Offset {
                                                    val newY = y.value + dragDistance.y
                                                    x.value = x.value + dragDistance.x
                                                    y.value = newY
                                                    return dragDistance
                                                }
    
                                                override fun onStop(velocity: Offset) {
                                                    // Todo what is the best method of determining what box the component is dragged on
                                                }
                                            })
                                    ) {
                                        Text(text = "Dragme", modifier = Modifier.align(Alignment.Center))
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    👍 2
    • 1
    • 1
  • m

    Manuel Lorenzo

    10/06/2020, 7:01 AM
    Hi everybody! I've been trying to wrap my head around compose and the way of creating UI in a declarative way by doing some of the code labs and trying to adapt a small app I have that makes a couple of API requests to an external API by using flow and Retrofit. Nevertheless I'm having some troubles observing the data in the ViewModel and just showing the results in a recycler view in the fragment. I haven't run into any example that does similar things, not even in the compose samples. Does anybody know any tutorial or repo that I can take a look at? Thanks a lot in advance!
    a
    c
    +2
    • 5
    • 4
  • k

    Kyant

    10/06/2020, 11:40 AM
    How to make
    Dialog
    (not
    AlertDialog
    ) full width?
    k
    a
    v
    • 4
    • 3
  • a

    Ash

    10/06/2020, 3:37 PM
    Bothered by the fact that all @Compose UI components are in the Global namespace. As someone who does not start a project without DI and a clear Architecture this keeps bothering me. SwiftUI & Objective-C same issue How are people handling working in super large teams with name clashes ??? Wrap everything in a companion object just to get the namespace? Wondering if missing something ...
    r
    r
    +2
    • 5
    • 21
  • d

    Davide Giuseppe Farella

    10/06/2020, 4:31 PM
    Hey guys, given a
    Column {
      Text(...)
      Image(...)
    }
    which is the best way to let the the Text.width to be at most as Image.width? I don’t want the Text to exceed the Image size
    z
    m
    • 3
    • 7
Powered by Linen
Title
d

Davide Giuseppe Farella

10/06/2020, 4:31 PM
Hey guys, given a
Column {
  Text(...)
  Image(...)
}
which is the best way to let the the Text.width to be at most as Image.width? I don’t want the Text to exceed the Image size
z

Zach Klippenstein (he/him) [MOD]

10/06/2020, 4:48 PM
Probably with intrinsics? There's a section in the docs about this, I can dig it up if you haven't seen it
🙏 1
d

Davide Giuseppe Farella

10/06/2020, 4:52 PM
Can you share me the link pls? I can dig myself 🙂 Thank you 🙂
m

mattinger

10/06/2020, 5:16 PM
You could also use a ConstrantLayout as well, attach the image to the left and right of the parent, and attach the text to the left and right of the image. this should force the text to match the image width. It’ might be overly complex but it should work.
z

Zach Klippenstein (he/him) [MOD]

10/06/2020, 5:29 PM
https://codelabs.developers.google.com/codelabs/jetpack-compose-layouts/index.html?index=..%2F..index#9
I’m not sure how the text’s intrinsic width would interact with the image’s intrinsic width, but this sounds like something they’d designed for
d

Davide Giuseppe Farella

10/06/2020, 5:53 PM
Thank you, I was hoping in an easier solution 😋 I'll take a look at both of the solutions, thanks
z

Zach Klippenstein (he/him) [MOD]

10/06/2020, 6:30 PM
A third solution is to just make a custom
Layout
that knows it only has two children, and what those children are, and can explicitly size itself appropriately. Making custom layouts is pretty easy with compose, so that might actually be easier/more readable/maintainable than using intrinsics depending how confusing they are.
🙏 1
View count: 1