Yann Badoual
10/16/2020, 7:10 PMGuy Bieber
10/16/2020, 7:29 PMGuy Bieber
10/16/2020, 7:41 PMGuy Bieber
10/16/2020, 7:41 PMGuy Bieber
10/16/2020, 7:43 PMGuy Bieber
10/16/2020, 7:53 PMRonnie Magatti
10/16/2020, 10:18 PMalpha05
I’ve put up a minimum reproducible example here but the Tl;DR is: text fields either don’t seem to be grabbing focus when they should, or they are but still won’t bring up the keyboard.
On the MRE, downgrading compose_version
to alpha04
seems to “fix” the issue.
The MRE was created on AS Canary 13 selecting new project -> compose activity.Sergey B
10/17/2020, 9:09 AMNat Strangerweather
10/17/2020, 4:29 PMHitanshu Dhawan
10/17/2020, 6:16 PMMihai Hrincescu
10/17/2020, 9:12 PM@Composable
to not get cliped by the parent? I already tried using Modifier.drawLayer(clip = false)
but it seems to have no effect.jaqxues
10/18/2020, 7:40 AMAditya Wasan
10/18/2020, 8:56 AMLazyColumnForIndexed
where the items change due to a boolean condition. However, if I've scrolled more than the size of the second list and then try to switch to the second list the app crashes with
java.lang.IllegalStateException: entered drag with non-zero pending scroll: -1638.0
Just wanted to know if it's a bug or that's how it is intended to work.
LazyColumnForIndexed(
items = if (showSaved.value) savedPostsState.value else hottestPostsState.value,
modifier = Modifier.padding(horizontal = 8.dp)
) { index, item ->
pavi2410
10/18/2020, 3:03 PMCash Hsiao
10/19/2020, 7:49 AMMaik
10/19/2020, 8:23 AM// IntelliJ API Decompiler stub source generated from a class file
// Implementation of methods is not available
package androidx.compose.foundation.layout
@kotlin.PublishedApi internal val DefaultRowMeasureBlocks: androidx.compose.ui.node.LayoutNode.MeasureBlocks /* compiled code */
@androidx.compose.runtime.Composable public inline fun Row(modifier: androidx.compose.ui.Modifier /* = compiled code */, horizontalArrangement: androidx.compose.foundation.layout.Arrangement.Horizontal /* = compiled code */, verticalAlignment: androidx.compose.ui.Alignment.Vertical /* = compiled code */, children: @androidx.compose.runtime.Composable() (androidx.compose.foundation.layout.RowScope.() -> kotlin.Unit)): kotlin.Unit { /* compiled code */ }
@kotlin.PublishedApi @androidx.compose.runtime.Composable internal fun rowMeasureBlocks(horizontalArrangement: androidx.compose.foundation.layout.Arrangement.Horizontal, verticalAlignment: androidx.compose.ui.Alignment.Vertical): androidx.compose.ui.node.LayoutNode.MeasureBlocks { /* compiled code */ }
I would be glad about some helpful tips.Antanas A.
10/19/2020, 9:52 AMSergey Y.
10/19/2020, 10:14 AMP.J.
10/19/2020, 11:15 AMDaniele B
10/19/2020, 1:03 PMzoha131
10/19/2020, 1:21 PMimport androidx.compose.animation.animate
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.Image
import androidx.compose.foundation.Text
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Layout
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.drawscope.translate
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.dp
import androidx.ui.tooling.preview.Preview
@Composable
fun CategoryButton(modifier: Modifier = Modifier) {
val (checked, setChecked) = remember { mutableStateOf(false) }
Surface(
modifier = modifier
.clip(RoundedCornerShape(4.dp))
.clickable {
setChecked(!checked)
},
shape = RoundedCornerShape(4.dp)
) {
CategoryButtonLayout(isChecked = checked, modifier = modifier)
}
}
@Composable
private fun CategoryButtonLayout(isChecked: Boolean, modifier: Modifier) {
Layout(
children = { CategoryButtonContent(isChecked) },
modifier = modifier,
measureBlock = { miserables, constraints ->
val width = constraints.maxWidth
val height = 48.dp.toIntPx()
val canvasConstraints = Constraints(
maxHeight = height,
minHeight = height,
maxWidth = width,
minWidth = width
)
val iconSize = 24.dp.toIntPx()
val iconConstraints = Constraints(
minHeight = iconSize,
maxHeight = iconSize,
minWidth = iconSize,
maxWidth = iconSize
)
val canvasPlaceable = miserables[0].measure(canvasConstraints)
val iconPlaceable = miserables[1].measure(iconConstraints)
val textPlaceable = miserables[2].measure(constraints)
layout(width, height) {
canvasPlaceable.place(0, 0)
iconPlaceable.place(8, height / 2 - iconPlaceable.height / 2)
textPlaceable.place(iconSize, height / 2 - textPlaceable.height / 2)
}
}
)
}
@Composable
private fun CategoryButtonContent(isChecked: Boolean) {
val textColor = if (isChecked) Color.White else Color.Black
val textColorAnimated = animate(textColor)
val radius = if (isChecked) 550.dp else 4.dp
val radiusAnimated = animate(radius)
Canvas(
modifier = Modifier.fillMaxSize(),
onDraw = {
val left = size.width / 2
// To move the center of the circle
translate(left, 0f) {
drawCircle(color = Color.Red, radius = radiusAnimated.toIntPx().toFloat())
}
drawLine(
color = Color.Red,
start = Offset(size.width, 0f),
end = Offset(size.width - 8.dp.toIntPx().toFloat(), 0f),
strokeWidth = size.width
)
}
)
Image(
asset = Icons.Filled.Close,
colorFilter = ColorFilter.tint(textColorAnimated),
contentScale = ContentScale.Fit
)
Text(
style = MaterialTheme.typography.button.copy(color = textColorAnimated),
text = "COVID 19",
maxLines = 1
)
}
@Preview
@Composable
fun CategoryButtonPreview() {
Box(
Modifier.fillMaxWidth()
) {
CategoryButton()
}
}
@Preview
@Composable
fun CategoryButtonRowBoxPreview() {
Row(
Modifier.fillMaxWidth()
) {
Box(
Modifier.fillMaxWidth().weight(1f)
) {
CategoryButton()
}
Box(
Modifier.fillMaxWidth().weight(1f)
) {
CategoryButton()
}
}
}
@Preview
@Composable
fun CategoryButtonRowPreview() {
Row(
Modifier.fillMaxWidth()
) {
CategoryButton(
modifier = Modifier.fillMaxWidth().weight(1f)
)
CategoryButton(
modifier = Modifier.fillMaxWidth().weight(1f)
)
}
}
Afzal Najam
10/19/2020, 1:52 PMDaniele B
10/19/2020, 2:43 PMTopAppBar
are defined?
I tried to look for its implementation (by hitting CMD-B), but it’s not available from Android Studiozoha131
10/19/2020, 3:45 PMSurface(
elevation = 16.dp
) {
Text(text = "Hello World", modifier = Modifier.padding(16.dp))
}
But if I add Modifier.drawLayer(shadowElevation = 16f
then I get shadow. Now my qs is. shouldn’t elevation give us the shadow/elevation?caelum19
10/19/2020, 4:13 PMDaniele B
10/19/2020, 4:16 PMmattinger
10/19/2020, 6:53 PMTash
10/19/2020, 8:02 PMfabio.carballo
10/19/2020, 9:22 PMVsevolod Ganin
10/19/2020, 11:07 PMLazyColumnFor
. When I use positional remember
inside itemContent
, it remembers everything for that particular index in the list. So when I remove an item in the source list, the (index + 1) item takes its place and inherits the memory of its predecessor. I think that’s because of the usage of key(index)
in LazyColumnFor
implementation. Is this intended?