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
  • a

    Ankit Dubey

    08/01/2021, 2:52 PM
    [ Resolved ] Hi, I’m facing issue in animating transition in Compose.
    var mProgress by remember { mutableStateOf(0F) }
    
    val transition = updateTransition(targetState = mProgress, label = "")
    Currently, On Button Click, I can easily change mProgress value and view will be animated But I’ve don’t want to animate on Button Clicked, rather the view should be animated as soon as it is displayed in screen. Tried a lot of things but no luck 😞 Any suggestion ?
    a
    f
    • 3
    • 3
  • d

    Daniel Weidensdörfer

    08/01/2021, 3:32 PM
    Let's say I have a
    Scaffold
    and I show a snackbar by calling
    scaffoldState.snackbarHostState.showSnackbar(...)
    . The snackbar is shown above the fab. What can I do to make the snackbar move the fab up when it is shown and down when it disappears?
    i
    c
    +2
    • 5
    • 10
  • k

    K Merle

    08/01/2021, 6:45 PM
    I have a
    OutlinedTextField
    and
    var email by rememberSaveable { mutableStateOf("") }
    inside single compose function. Upon rotating screen, email state value resets to
    ""
    . Shouldn't
    rememberSaveable
    actually keep value of an email and not reset it?
    c
    s
    • 3
    • 12
  • a

    Abdalla Hassanin

    08/02/2021, 4:37 AM
    I want to understand what is meant by "Unbundled from OS" In compose
    j
    • 2
    • 2
  • s

    Sudhir Singh Khanger

    08/02/2021, 4:55 AM
    When does a composable function go into composition and when does it leave composition? I can see I can call a Composable function for it to be displayed on the screen but how do you remove it?
    l
    • 2
    • 2
  • r

    rkeazor

    08/02/2021, 5:41 AM
    When trying to use preview I get an error saying "PreviewActivity is not a Activity subclass or alias" . Anyone know how to resolve this?
    c
    r
    • 3
    • 3
  • d

    Daniel Weidensdörfer

    08/02/2021, 9:33 AM
    Are there any plans for an autosized text in compose?
    e
    • 2
    • 2
  • d

    Daniele Segato

    08/02/2021, 9:45 AM
    When using
    AnimatedVisibility
    how can I make the container scroll to show the item being expanded? (say I'm at the end of the scroll and there's an expandable item
    👀 1
    c
    z
    a
    • 4
    • 8
  • m

    MaxUt

    08/02/2021, 10:14 AM
    What is the best way to force children composable to be placed in their parents ? I'm struggling with text rotation. I decided to rotate a row containing text instead of rotating each individual texts. I managed to keep proportion by switching width and height with a customer modifier, however I can't figure out how to force children element to stay at the position of their parent.
    z
    • 2
    • 6
  • j

    JulianK

    08/02/2021, 10:32 AM
    I'm experiencing memory leaks with compose 1.0 and navigation-compose 2.4.0-alpha05, which introduces crossfade. After a few navigations triggered by my bottom bar, i see multiple instances of my screen functions on the heap, one instance per navigation. They don't get garbage collected. No Leaks with navigation-compose alpha04. Anyone else experiencing this issue?
    i
    • 2
    • 1
  • a

    Anastasia Rozovskaya

    08/02/2021, 10:32 AM
    Is it possible to give an
    OutlinedTextField
    elevation with shadow? I tried to apply
    Modifier.shadow(elevation = 8.dp, shape = RoundedCornerShape(8.dp))
    directly to OutlinedTextField, but the result was horrible. Should I use
    BasicTextField
    instead? I see some
    decorationBox
    parameter in there, which might help.
    k
    • 2
    • 11
  • t

    Tin Tran

    08/02/2021, 10:43 AM
    I have a question about
    HorizontalPager
    . If each page have difference height then the
    HorizontalPager
    will match the size of the largest page is that correct?
    • 1
    • 3
  • m

    Mehdi Haghgoo

    08/02/2021, 10:46 AM
    For some reason the four images I put in a row do not fill the whole available width. Does anyone know why this is happening?
    Row(Modifier.fillMaxSize().background(Color.Yellow)) {
        val pics = listOf(R.drawable.professor, R.drawable.woman,
        R.drawable.daughter, R.drawable.son)
        for (pic in pics)
            Image(painterResource(id = pic), null, Modifier.fillMaxWidth(0.25f).align(Alignment.Bottom))
    }
    a
    • 2
    • 2
  • m

    muthuraj

    08/02/2021, 11:24 AM
    Hi, does anyone know how to save/retain keyboard focus and cursor position for a
    TextField
    ? I'm having a list screen with a search option and showing either list or error screen below the search box based on search results. It roughly looks like this for list state
    Column{
    SearchBox()
    List()
    }
    and like this for error state
    Column{
    SearchBox()
    Text("No results")
    }
    SearchBox
    has
    BasicTextField
    and other decorations around it. Now when I start typing in the search box, the keyboard state and cursor position is retained for recompositions of the list screen update, but when the error state is shown, the keyboard is being closed and the
    TextField
    loses focus. The same happens when transitioning from error state to list screen.
    z
    • 2
    • 6
  • e

    emmanuelvinas

    08/02/2021, 12:03 PM
    Hi, I’m experiencing something weird with the compose compiler.
    import androidx.compose.runtime.Composable
    import androidx.compose.ui.graphics.BlendMode
    
    @Composable
    fun TestBlendMode(
        blendMode: BlendMode = BlendMode.Multiply
    ) {
        // Comment this line and compilation should work as expected
        val mode = blendMode
    }
    If i use a blendmode inside a composable, i get a crash. Anyone getting the same error with the 1.0.0 version?
    : java.lang.AssertionError: Assertion failed
            at org.jetbrains.kotlin.ir.util.AdditionalIrUtilsKt.getPropertyGetter(AdditionalIrUtils.kt:236)
            at androidx.compose.compiler.plugins.kotlin.lower.AbstractComposeLowering.unboxValueIfInline(AbstractComposeLowering.kt:311)
    l
    • 2
    • 1
  • m

    Mohamed Ibrahim

    08/02/2021, 12:10 PM
    I have this problem where typography is not reflected in Android studio preview? anyone facing same problem
    a
    a
    • 3
    • 3
  • a

    Andrey Kulikov

    08/02/2021, 12:20 PM
    Added a simple demo on how to implement a fullscreen tutorial overlay which highlights one of the buttons on the screen. In case someone was curious how to implement that in Compose. The code is here
    device-2021-08-02-124328.mp4
    :kotlin-intensifies: 12
    👍🏼 4
    👍🏾 1
    👍🏻 2
    👍 29
    c
    n
    • 3
    • 3
  • a

    Akram Bensalem

    08/02/2021, 1:05 PM
    In animation between screens (navigation) is available now ?!
    c
    n
    +3
    • 6
    • 8
  • a

    Anders Kielsholm

    08/02/2021, 1:50 PM
    Hi! 🙂 I have a usecase where I would like my LazyColumn to scroll to the top if I add a new item to the start of the list - but only if the list was scrolled to top before. Anyone knows how to do that? Think it's something like using a
    LaunchedEffect
    , but can't really wrap my head around it 🙂 I'm using keys so the list is in general keeping the same position when adding items 🙂
    ➕ 1
    m
    • 2
    • 6
  • m

    Magomedov Abakar

    08/02/2021, 2:38 PM
    Hello everyone !) Can I use styles from xml with Text() composable function ?) Or I should rewrite all my style system ?
    a
    • 2
    • 1
  • i

    Ink

    08/02/2021, 2:42 PM
    Hi! How can I create TextFild like that? I try:
    TextField(
        value = titleState.value,
        onValueChange = { titleState.value = it },
        colors = TextFieldDefaults.textFieldColors(
            textColor = MaterialTheme.colors.primary,
            disabledTextColor = Color.Transparent,
            backgroundColor = Color.Transparent,
            focusedIndicatorColor = Color.Transparent,
            unfocusedIndicatorColor = Color.Transparent,
            disabledIndicatorColor = Color.Transparent
        )
    )
    The problem is when I want to put down text there is a text instead of hint and I have to delete text before typing the proper word
    l
    z
    +2
    • 5
    • 12
  • m

    MBegemot

    08/02/2021, 3:20 PM
    What this message means 'Modifier factory functions must use the receiver Modifier instance' When writing a modifier like fun Modifier.myModifier(i:Int):Modifier{ return Modifier.border(BorderStroke(1.dp,Color.Blue),RoundedCornerShape(6.dp))} It works as expected ...
    z
    • 2
    • 4
  • c

    Colton Idle

    08/02/2021, 5:53 PM
    Not strictly compose related... but I created a new app using the Compose template in Android studio. Does the status bar seem weirdly tall to you? I have NoActionBar, and only a statusBarColor set. Should I be doing something different in the theme for a strictly compose app?
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style name="Theme.MyApp" parent="android:Theme.Material.Light.NoActionBar">
            <item name="android:statusBarColor">@color/purple_700</item>
        </style>
    </resources>
    s
    r
    • 3
    • 5
  • z

    zsperske

    08/02/2021, 7:24 PM
    Is it expected that recomposition will not happen if the
    data class
    which represents my UI state contains a
    var
    and that var changes?
    data class EventListState(val events: List<EventUiModel> = emptyList(),
                              var eventDestination: String = "", //Changes to this var do not cause recomposition
                              val pastEventsSelected: Boolean = false,
                              val isLoading: Boolean = true)
    :yes: 1
    c
    z
    • 3
    • 7
  • j

    Jason Inbody

    08/02/2021, 8:01 PM
    I'm trying to wrap my head around the navigation and I've got a bottom Nav bar that's working great so far and can switch between screens from the bottom. I need to implement stack views with back buttons inside each bottom nav bar tab. So when a user starts switching views inside a tab the current screen sticks if they click on another tab the state of the other tab is remembered. I'm reading over this (https://medium.com/google-developer-experts/navigating-in-jetpack-compose-78c78d365c6a) and it looks like kind of like what I need but unsure how it jives with a bottom nav bar. And this is my bottom nav bar that I pulled out of a demo app
    @Composable
    fun Navigation(user: FinUser, navController: NavHostController) {
        NavHost(navController, startDestination = NavigationItem.MapScreen.route) {
            composable(NavigationItem.Account.route) {
                Account(user = user)
            }
            composable(NavigationItem.History.route) {
                History(user = user)
            }
            composable(NavigationItem.MapScreen.route) {
                MapScreen(user = user)
            }
            composable(NavigationItem.Promo.route) {
                Promo(user = user)
            }
            composable(NavigationItem.Help.route) {
                Help(user = user)
            }
        }
    }
    
    @Composable
    fun BottomNavigationBar(user: FinUser, navController: NavController) {
        val items = listOf(
            NavigationItem.Account,
            NavigationItem.History,
            NavigationItem.MapScreen,
            NavigationItem.Promo,
            <http://NavigationItem.Help|NavigationItem.Help>
        )
        BottomNavigation(
            backgroundColor = MaterialTheme.colors.primary,
            contentColor = Color.White
        ) {
            val navBackStackEntry by navController.currentBackStackEntryAsState()
            val currentRoute = navBackStackEntry?.destination?.route
            items.forEach { item ->
                BottomNavigationItem(
                    icon = { Icon(item.icon, contentDescription = item.iconName) },
                    label = { Text(text = item.title) },
                    selectedContentColor = Color.White,
                    unselectedContentColor = Color.White.copy(0.4f),
                    alwaysShowLabel = true,
                    selected = currentRoute == item.route,
                    onClick = {
                        navController.navigate(item.route) {
                            // Pop up to the start destination of the graph to
                            // avoid building up a large stack of destinations
                            // on the back stack as users select items
                            navController.graph.startDestinationRoute?.let { route ->
                                popUpTo(route) {
                                    saveState = true
                                }
                            }
                            // Avoid multiple copies of the same destination when
                            // reselecting the same item
                            launchSingleTop = true
                            // Restore state when reselecting a previously selected item
                            restoreState = true
                        }
                    }
                )
            }
        }
    }
    :thread-please: 5
    c
    j
    c
    • 4
    • 5
  • j

    Jason Inbody

    08/02/2021, 8:02 PM
    This
    composable(NavigationItem.Help.route) {
                Help(user = user)
            }
    makes sense for doing top level routing but what about nested routing?
    • 1
    • 1
  • a

    Alexander Karkossa

    08/02/2021, 8:55 PM
    The new navigation_compose 2.4.0-alpha05 introduced crossfade. At the moment i used "Scaffold per Screen". Each screen in the application has its own Scaffold because some screens should show an docked FAB in the BottomBar. Now, with navigation 2.4.0-alpha05, my blue BottomBar flickers on every navigation, because of the crossfade. I think the solution is to put the scaffold out of the screens -> One global Scaffold Could someone give me an example on how to use the navigation library in compose with one Scaffold around the NavHost. Screen A should not show a fab, Screen B should show the docked FAB. My problem is the fab click handling
    n
    c
    +4
    • 7
    • 16
  • r

    rsktash

    08/03/2021, 12:03 AM
    How to handle press down and up events?
    z
    c
    • 3
    • 7
  • z

    Zach Klippenstein (he/him) [MOD]

    08/03/2021, 12:05 AM
    We’re implementing a custom Switch component, and noticed that we have to do some math with the
    SwipeableState.offset
    when the layout direction is Rtl to draw the thumb on the right side. The gesture direction is correct though. Should
    SwipeableState.offset
    return inverted values in Rtl mode? If so, I can file a bug.
    c
    a
    • 3
    • 5
  • i

    Ink

    08/03/2021, 12:53 AM
    Is it possible to create ViewPager or horizontal ScrollView with images?
    c
    • 2
    • 1
Powered by Linen
Title
i

Ink

08/03/2021, 12:53 AM
Is it possible to create ViewPager or horizontal ScrollView with images?
c

Colton Idle

08/03/2021, 2:05 AM
https://google.github.io/accompanist/pager/
View count: 2