daivid
05/28/2021, 7:40 PManimatedVectorResource
and the AnimatedImageVector
’s painterFor
, it seems that all I can control is the direction of the animation with atEnd
.
Is there a way to get more control over the animated vector animation? I’d like to be able to loop the animated vector’s animation infinitely. Ideally with multiple steps to the animation (to improve the waviness of my background)Tiago Nunes
05/28/2021, 8:37 PM@Composable
fun HeaderCards(users: List<User>) {
LazyRow(
contentPadding = PaddingValues(horizontal = 10.dp),
modifier = Modifier
.fillMaxWidth(),
) {
items(users) { user ->
HeaderCard(user)
}
}
}
Daniel
05/28/2021, 10:08 PMIn addition to providing the ability to draw into a specified bounded area,However, the entire public api is just the propertyprovides a few high level mechanisms that consumers can use to configure how the content is drawn.Painter
intrinsicSize
and the extension function DrawScope.draw
. Confusingly draw
doesn't take the painter as an argument, so I'm not sure how it could work.
This is as far as I got:
val painter = painterResource(R.drawable.marker)
val size = painter.intrinsicSize
val image = ImageBitmap(size.width.roundToInt(), size.height.roundToInt())
val canvas = Canvas(image)
CanvasDrawScope().draw(LocalDensity.current, LocalLayoutDirection.current, canvas, size) {
}
tad
05/28/2021, 11:21 PMDaniel
05/29/2021, 12:07 AMBox(Modifier.fillMaxSize()) {
AndroidView(/* ... */)
when (foo) {
is Bar -> Box(Modifier.fillMaxSize().pointerInput(key) { /* ... */ }
is Buzz -> Box(Modifier.fillMaxSize().pointerInput(key) { /* ... */ }
/ * ... */
}
}
The problem is both Modifier.pointerInteropFilter
(even returning false) and Modifier.pointerInput
(even with an empty block) prevent the view from seeing any pointer events.Michael Paus
05/29/2021, 5:14 AMAbdalla Hassanin
05/29/2021, 9:58 AMAkram Bensalem
05/29/2021, 9:58 AMAndré Thiele
05/29/2021, 12:28 PMhttps://youtu.be/0z_dwBGQQWQ?t=968▾
Michal Klimczak
05/29/2021, 1:26 PM//causes infinite recomposition
val playerUiStateWrong by player.observeState()
.map { PlayerUIState(it, sound) }
.collectAsState(PlayerUIState(null, null))
//works fine
val playerState by player.observeState().collectAsState(PlayerState.Stopped)
val playerUiState = PlayerUIState(playerState, sound)
I thought they would both do the same thing, but the first one, whenever I use playerUiStateWrong
as a parameter in a modifier, causes infinite recompositions, whereas the second one works fine.Sunny
05/29/2021, 2:26 PMcodeslubber
05/29/2021, 2:30 PMtheapache64
05/29/2021, 4:34 PMZun
05/29/2021, 7:03 PMDaniel
05/29/2021, 11:26 PMAndré Thiele
05/30/2021, 9:00 AMShakil Karim
05/30/2021, 10:59 AMYuri Drigin
05/30/2021, 11:13 AMjava.lang.IllegalStateException: pending composition has not been applied
in this code. Where I’m wrong?Tiago Nunes
05/30/2021, 11:46 AMRow {
columns.forEach {
Card(Modifier.weight(1f))
}
}
In my case the number of columns is dynamic, and the max number of columns is 3
And I get a row looking like this, when I have 3 columns: (each card has weight 1)
[ ] [ ] [ ]
And when there is only 1 column, I get this: (each card has weight 1)
[ ]
I wanted to get this: (each card has weight 1, weight sum is 3)
[ ]Vitaliy Zarubin
05/30/2021, 12:30 PMKirill Grouchnikov
05/30/2021, 12:49 PMLazyColumn
? Something like this multi-column layout (which might be for tablets on Android, or for larger screens on desktop) where the middle column is a lazily loaded list of articles / emails / etc, and the right column is the full detail of the selected element.Hachemi Hamadi
05/30/2021, 12:54 PMval scale = remember { mutableStateOf(1f) }
Box(modifier = Modifier
.height(250.dp)
.fillMaxWidth()
.background(color = Color.White)
.graphicsLayer(
scaleX = maxOf(.5f, minOf(3f, scale.value)),
scaleY = maxOf(.5f, minOf(3f, scale.value)),
)
.pointerInput(Unit) {
detectTransformGestures { centroid, pan, zoom, rotation ->
scale.value *= zoom
}
}
)
Aditya Thakar
05/30/2021, 1:31 PMNikhil
05/30/2021, 5:54 PMDrawModifier
and I’m drawing the shadows using contentDrawScope
provided by DrawModifier
.
1. First of all, Is this a correct to extend the modifiers?
2. To render the shadows(GradientDrawable) smoothly, I’m using RenderScript (I know it’s going to be deprecated in the Android12. I’ll migrate.). I need context
param to invoke renderscript api. Is it okay to pass context
param in the Modifier?Zhelyazko Atanasov
05/30/2021, 6:07 PMTextField
/ text input. I'm building an app for mobile phones that have hardware barcode scanners. When the user scans a barcode, the actual barcode is transmitted as a sequence of key events. In a View
world I have an EditText
that is focused, so when a user scans a barcode, its value is entered into the EditText
and I can just do editText.text.toString()
to get the value of the scanned barcode + the user sees what was scanned. As the user is expected to use the barcode scanner for input, the on-screen software keyboard must not be shown. This was easy to do with EditText
.
Now I wanted to replicate the same functionality in Compose using a TextField
. Unfortunately, I can't find a way how to do that. If you specify readOnly = true
, then the CoreTextField
doesn't use the TextInputService
and the TextField is not listening for any input key events. It seems that readOnly
is suited for cases where we'll just display data, like a Calculator app.
Then I went deeper into `CoreTextField`'s implementation and decided to try another approach. I created a composable that didn't use any TextField
. Instead, I got a reference to the LocalTextInputService.current
, created an EditProcessor
instance and called startInput()
like so:
@Composable
fun ScannerInput() {
val textInputService = LocalTextInputService.current
var textFieldValue = remember { mutableStateOf(TextFieldValue()) }
val editProcessor = EditProcessor()
textInputService?.startInput(
value = textFieldValue.value,
imeOptions = ImeOptions.Default.copy(singleLine = true),
onEditCommand = {
val newValue = editProcessor.apply(it)
Log.d("Scanner", "onEditCommand: $newValue")
},
onImeActionPerformed = {
Log.e("Scanner", "onImeActionPerformed: $it")
}
)
}
The thing is that down into the implementation of TextInputService
, it's making a call to showSoftwareKeyboard()
and the keyboard is shown 😞
Any idea what else I could try, as this is a core part of my app and the requirement is strictly never to show the on-screen software keyboard 🤔Alexander Karkossa
05/30/2021, 8:37 PMcompose 1.0.0-beta07
various items disappear when scrolling in LazyColumn
. I could reproduce the problem in a minimal example by inserting a Box
inside a LazyColumn
between AnimatedVisibility
and the actual Card
(the same happens with e.g. Column
). Example in my answerTlaster
05/31/2021, 3:29 AMColton Idle
05/31/2021, 4:35 AMCrossfade()
?
The docs state that you CAN crossfade, but not exactly how? I also looked at Owl sample app but didn't see usage of crossfade either.Sunny
05/31/2021, 6:30 AMiamthevoid
05/31/2021, 6:59 AMiamthevoid
05/31/2021, 6:59 AMArkadii Ivanov
05/31/2021, 9:21 AMiamthevoid
05/31/2021, 9:38 AMArkadii Ivanov
05/31/2021, 9:39 AMiamthevoid
05/31/2021, 9:43 AMArkadii Ivanov
05/31/2021, 9:46 AMAnimatedVisibity
will help?iamthevoid
05/31/2021, 10:12 AMArkadii Ivanov
05/31/2021, 10:14 AM