Denis
03/05/2021, 6:25 PMDataTable
that was removed last year?Nikola Drljaca
03/05/2021, 7:46 PMviewModel
when using navigation-compose
?gpaligot
03/05/2021, 8:45 PMBox
with a CircleShape
. My shadow is displayed but it isn’t the same shadow applied around all my shape. Can it be possible to avoid a bigger shadow at the bottom and to have the exact same shadow around all the box?
@Composable
fun CircleProgress(
angle: Int
) {
Box(
Modifier
.fillMaxSize()
.padding(80.dp)
.shadow(elevation = 8.dp, shape = CircleShape)
.background(color = Color.White, shape = CircleShape)
.padding(10.dp)
.drawBehind {
drawArc(
color = Color.Red,
startAngle = -90f,
sweepAngle = angle.toFloat(),
useCenter = false,
style = Stroke(width = 30f, cap = StrokeCap.Round)
)
}
)
}
Thanks in advance!Vivek Sharma
03/05/2021, 8:51 PMvar state1 by remember { mutableStateOf(1) }
var state2 by remember { mutableStateOf(100 - state1) }
I am having kind of this code, I am updating state1
and state2 should update when state1 update
, but state2 is not getting updated
, am I doing something wrong?Mehdi Haghgoo
03/05/2021, 9:12 PMyahyabayramoglu
03/05/2021, 9:20 PMCard
? 😅
Card has fixed size, and it only contains a Text which needs to be centered.
This is literally the only way I could get it work - I must be doing something wrong here 🙂
Card(modifier = Modifier.size(50.dp).padding(4.dp)) {
Row(verticalAlignment = Alignment.CenterVertically) {
Text(
text = "10",
textAlign = TextAlign.Center,
fontSize = 10.sp,
modifier = Modifier.fillMaxWidth()
)
}
}
Law Gimenez
03/06/2021, 7:10 AMModifier.preferredHeight(16.dp)
. So what is the fix for this?Sudhir Singh Khanger
03/06/2021, 8:42 AMMaterialTheme.colors.onSurface
in a Composable. Cursor hover tells me
org.jetbrains.kotlin.diagnostics.SimpleDiagnostic@9406416a (error: could not render message)
whereas the build window tells me @Composable invocations can only happen from the context of a @Composable function
But I am using it inside a Composable function.Shivam Sethi
03/06/2021, 8:50 AMelye
03/06/2021, 10:45 AMBradleycorn
03/06/2021, 2:22 PMColumn
and I want it's content to be centered (vertically) on the screen, I can do:
Column(modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center) { ... }
But what if I don't want it centered vertically, but instead want (the top of) it to be offest 35% from the top of the screen?
I can use the offset
modifier (offset(y=100.dp)
) to place it a certain amount from the top, but I want to specify the offset by percentage, not dp ...jaqxues
03/06/2021, 5:01 PMGabriel
03/06/2021, 7:21 PMcomposeable
inside a navhost
that takes an arg as part of it's route, I can get it as part of the arguments passed to the composable, but when I try to get it from the viewmodel inside a @Composable
it's not present, https://gist.github.com/gabriel403/61c149a491e7701314b6a895e1a48df0A. Sachdeva
03/06/2021, 7:53 PMShivam Sethi
03/06/2021, 10:19 PMRick Regan
03/07/2021, 12:40 AMButton
to respond to both a press and a long press? I tried modifier .pointerInput
with detectTapGestures
and onLongPress
but it does not detect the long press (or any of the other gestures).
If I include a Text
in the Button I can get the long press to work on the text portion, but I want to cover the whole button. (See code in thread.)
Edit: I can't get Modifier.combinedClickable
to do it either (see second code example in thread).Konyaco
03/07/2021, 5:20 AMShivam Sethi
03/07/2021, 7:26 AMOlivier Patry
03/07/2021, 11:37 AMBackdropScaffold
with a nullable front content.
The front content is well displayed when not null, then when state is updated to null
previous state remains.
@Composable
fun AppScreen() {
val viewModel = viewModel()
val state by viewModel.state.observeAsState(null)
BackdropScaffold(
appBar = { },
backLayerContent = {
Column(
Modifier.fillMaxWidth()
) {
//
Text("BACK")
}
},
frontLayerContent = {
state?.let { uiState ->
Text("FRONT")
}
}
)
}
To workaround this, I had to add an empty box:
state?.let { uiState ->
Text("FRONT")
} ?: Box {}
Is it expected?
When the state is null at the beginning nothing is displayed as expected without the workaround.Issa
03/07/2021, 11:56 AMPathway
first code lab Compose Basics
section Animating your list
I have noticed that LazyColumn
doesn’t remember the isSelected
state of the item when recomposing. I have copy pasted the code from the Pathway
and got the same results. Just when you scroll until the item is no more visible, when you scroll back the isSelected
state is lost. IMO this is wrong cuz the state should be cached anyway and when recomposing the compiler should consider the previous state.
Should I Hoist
the state of the Greeting
widget so I can manage it in the LazyColumn
scope or this is just a Compose Bug
? 🤔
Thanks in advance!Slackbot
03/07/2021, 12:36 PMMjahangiry75
03/07/2021, 12:36 PME/AndroidRuntime(21544): Process: co.newgates.speechtype, PID: 21544
E/AndroidRuntime(21544): java.lang.ArrayIndexOutOfBoundsException: length=5120; index=-2
E/AndroidRuntime(21544): at androidx.compose.runtime.SlotTableKt.groupSize(SlotTable.kt:2558)
E/AndroidRuntime(21544): at androidx.compose.runtime.SlotTableKt.access$groupSize(SlotTable.kt:1)
E/AndroidRuntime(21544): at androidx.compose.runtime.SlotReader.groupSize(SlotTable.kt:596)
E/AndroidRuntime(21544): at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2215)
E/AndroidRuntime(21544): at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2499)
E/AndroidRuntime(21544): at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:2625)
E/AndroidRuntime(21544): at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:406)
E/AndroidRuntime(21544): at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:724)
E/AndroidRuntime(21544): at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:100)
E/AndroidRuntime(21544): at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:437)
E/AndroidRuntime(21544): at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:411)
E/AndroidRuntime(21544): at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:34)
E/AndroidRuntime(21544): at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:112)
E/AndroidRuntime(21544): at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:43)
E/AndroidRuntime(21544): at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:72)
E/AndroidRuntime(21544): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:765)
E/AndroidRuntime(21544): at android.view.Choreographer.doCallbacks(Choreographer.java:580)
E/AndroidRuntime(21544): at android.view.Choreographer.doFrame(Choreographer.java:549)
E/AndroidRuntime(21544): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
E/AndroidRuntime(21544): at android.os.Handler.handleCallback(Handler.java:739)
E/AndroidRuntime(21544): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(21544): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(21544): at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime(21544): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(21544): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(21544): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime(21544): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
florent
03/07/2021, 12:53 PMmsomu
03/07/2021, 2:08 PMAnimatedVisibility
I’m getting this error org.jetbrains.kotlin.diagnostics.SimpleDiagnostic@4ae249ce (error: could not render message)
am I missing something?
I have added these annotations @ExperimentalAnimationApi
or @OptIn(ExperimentalAnimationApi::class)
Can
03/07/2021, 3:04 PMDaniel
03/07/2021, 3:42 PMBlendMode.SrcIn
appear to be incorrect.
Show the source image, but only where the two images overlap.
The destination image is not rendered, it is treated merely as a mask.
The color channels of the destination are ignored, only the opacity has an effect
The color channels of the destination are used. Assuming this just wraps the native equivalent, this would be the expected behavior.
Asking here to check I'm not missing something stupid before I file a bug.Piotr Prus
03/07/2021, 7:58 PMjava.lang.NullPointerException: Attempt to invoke interface method 'void androidx.compose.runtime.MutableState.setValue(java.lang.Object)' on a null object reference
at androidx.compose.ui.platform.AndroidComposeView.setLayoutDirection(AndroidComposeView.android.kt:930)
at androidx.compose.ui.platform.AndroidComposeView.onRtlPropertiesChanged(AndroidComposeView.android.kt:768)
at android.view.View.resolvePadding(View.java:20272)
at android.view.ViewGroup.resolvePadding(ViewGroup.java:7765)
at android.view.View.initializeScrollbarsInternal(View.java:6781)
at android.view.View.<init>(View.java:6112)
at android.view.ViewGroup.<init>(ViewGroup.java:697)
at android.view.ViewGroup.<init>(ViewGroup.java:693)
at android.view.ViewGroup.<init>(ViewGroup.java:689)
at android.view.ViewGroup.<init>(ViewGroup.java:685)
at androidx.compose.ui.platform.AndroidComposeView.<init>(AndroidComposeView.android.kt:115)
at androidx.compose.ui.platform.Wrapper_androidKt.setContent(Wrapper.android.kt:79)
at androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated(ComposeView.android.kt:175)
at androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow(ComposeView.android.kt:207)
at android.view.View.dispatchAttachedToWindow(View.java:20479)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3489)
at android.view.ViewGroup.addViewInner(ViewGroup.java:5278)
at android.view.ViewGroup.addView(ViewGroup.java:5064)
at androidx.fragment.app.FragmentContainerView.addView(FragmentContainerView.java:290)
at android.view.ViewGroup.addView(ViewGroup.java:5004)
at androidx.fragment.app.FragmentStateManager.addViewToContainer(FragmentStateManager.java:830)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:520)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2177)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2094)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1990)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7660)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Shivam Sethi
03/07/2021, 11:02 PMefemoney
03/07/2021, 11:02 PMAlexjlockwood
03/08/2021, 1:53 AMText
composable’s ascent
and descent
font metrics?
there seems to be an API to access a text line’s top
and bottom
in TextLayoutResult
, but nothing for ascent
and descent
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]ult.kt;l=260-274;drc=75473ddf27998fdb2105416a5f0505f492ee8ad5
or is there a different API that i need to use? 🤔 cc @Siyamed