Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – How to resize after adding a new element using Jetpack compose?

Posted on November 11, 2022 By

Solution 1 :

Yes there is.
You can use animateContentSize on your box modifier
then you declare an animationSpec like below:

Box(modifier = Modifier
    .animateContentSize(
        animationSpec = tween(
            durationMillis = 300,
            easing = LinearOutSlowInEasing
        )
    ).clip(RoundedCornerShape(4.dp))
)

Now if the AlertMessage appears it will animate the size of the box.
You can also create expandable cards with this approach.

This video may help you too.

Problem :

I wrote the composable below (shown as dialog). When viewState.errorCode != 0, another composable is shown. This all works fine, but the height of the box doesn’t adjust when the new composable becomes visible.This results in an ‘invisible overflow’ whereby a number of items are no longer visible. Is there a way to make the box dynamic so that it adjusts in height when a new element becomes visible?

Box(modifier = Modifier
    .clip(RoundedCornerShape(4.dp))) {
    Column(
        modifier = Modifier
            .background(MaterialTheme.colors.onPrimary, MaterialTheme.shapes.large)
            .padding(12.dp)
    ) {
        Text(stringResource(R.string.verify_hint, user.email).parseBold(), fontSize = 18.textDp, fontFamily = SourceSans)

        if (viewState.errorCode != 0) {

            AlertMessage(message = stringResource(id = viewState.errorCode), color = errorColor, padding = PaddingValues(top = 12.dp))
        }

        TextField(
            value = code,
            onValueChange = { code = it },
            label = { Text(stringResource(R.string.verification_code)) },
            colors = TextFieldDefaults.textFieldColors(backgroundColor = textFieldColor),
            singleLine = true,
            keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
            modifier = Modifier
                .fillMaxWidth()
                .padding(top = 12.dp, bottom = 12.dp)
        )

        NMButton(
            onClick = { viewModel.verify(user, code, verifyLogin, language = context.getLanguageBasedOnConfiguration()) },
            modifier = Modifier
                .fillMaxWidth()
                .padding(start = 0.dp, end = 0.dp),
            icon = R.drawable.ic_badge_check_solid,
            label = stringResource(R.string.verify)
        )
    }
    if (viewState.loading) {
        Loader()
    }
}
READ  [FIXED] android - APK size is increased due to audience-network.dex file
Powered by Inline Related Posts
Android Tags:android, android-jetpack-compose, android-jetpack-compose-text, android-studio, kotlin

Post navigation

Previous Post: [FIXED] android developer api – there is a ‘Late Initialization Error’ during flutter development
Next Post: [FIXED] android – How to set SSL pinning using retrofit for Firebase Realtime Database Url?

Related Posts

[FIXED] android – How to solve setting up this payment problem – paypal Android
[FIXED] java – How to make timePicker in Android Studio 3 Android
[FIXED] android – Is Fragment can contain NavController? Android
[FIXED] android – Transition delay in exoplayer playlist Android
[FIXED] android – Navigation Controller not Switching Fragments on Button Press Android
[FIXED] android – How to kill application process? Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What is a good substitute for condensed milk?
  • ¿Como el cuerpo te avisa cuando te va a dar un infarto?
  • What is the luxury brand of Jaguar?
  • Who is Big poppa baseball player?
  • What material are foam runners?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme