我正在学习伴奏寻呼机,我想在寻呼机上设置效果。
我想像文档一样使用lerp方法
Modifier.graphicsLayer {
// Calculate the absolute offset for the current page from the
// scroll position. We use the absolute value which allows us
// to mirror any effects for both directions
val pageOffset =
calculateCurrentOffsetForPage(page).absoluteValue
// We animate the scaleX + scaleY, between 85% and 100%
lerp(
start = 0.85f,
stop = 1f,
fraction = 1f - pageOffset.coerceIn(0f, 1f)).also { scale ->
scaleX = scale
scaleY = scale
}
// We animate the alpha, between 50% and …Run Code Online (Sandbox Code Playgroud) android kotlin android-jetpack-compose jetpack-compose-accompanist
我想在 Jetpack Compose 中使用 Lottie。这是我的代码
val logoAnimationComposition by rememberLottieComposition(
spec = LottieCompositionSpec.RawRes(
resId = R.raw.twitter_logo_motion
)
)
val logoAnimationProgress by animateLottieCompositionAsState(
composition = logoAnimationComposition,
isPlaying = true
)
LottieAnimation(
modifier = Modifier.size(
size = logoSize
),
composition = logoAnimationComposition,
progress = logoAnimationProgress
)
Run Code Online (Sandbox Code Playgroud)
我需要知道这个动画什么时候结束。
我可以用我从 UI 设计师那里知道的动画持续时间来处理它,但这不是一个好方法。
并且文档没有提及任何相关内容。
我能做些什么?
我有一个HorizontalPager
val pageCount = bannerList.size
val startIndex = Int.MAX_VALUE / 2
val pagerState = rememberPagerState(initialPage = 100)
HorizontalPager(
count = Int.MAX_VALUE,
state = pagerState,
contentPadding = PaddingValues(
horizontal = 20.dp
),
modifier = Modifier
.fillMaxWidth()
) { index ->
// content goes here
}
Run Code Online (Sandbox Code Playgroud)
我让它像横幅一样每 4 秒滚动一次LaunchedEffect
LaunchedEffect(
key1 = Unit,
block = {
repeat(
times = Int.MAX_VALUE,
action = {
delay(
timeMillis = 4000
)
pagerState.animateScrollToPage(
page = pagerState.currentPage + 1
)
}
)
})
Run Code Online (Sandbox Code Playgroud)
它每 4 …
我想使用 jetpack compose 创建一个可滑动组件并作为文档Gestures | JetpackCompose我应该使用rememberSwipeableState. 但当我想使用它时,我遇到了这个错误:
Cannot access 'rememberSwipeableState': it is internal in 'androidx.compose.material3'
Run Code Online (Sandbox Code Playgroud)
我应该怎么办?
众所周知,ComposableJetpack Compose 中的函数名称应以大写字母开头。但当Compose Desktop我使用大写字母作为我的Composable第一个字母时,编辑器会显示警告!
Function name 'App' should start with a lowercase letter
我只想从Android我的项目中复制并粘贴大量代码。
我该如何解决这个问题?
我需要更改Bitmap?或BitmapDrawable显示ImageBitmap它,coil
这是我的代码
val bitmap = BlurhashDecoder.decode(blurhash, 4, 3)
Image(
bitmap = bitmap as ImageBitmap,
modifier = modifier,
contentScale = ContentScale.Crop,
contentDescription = ""
)
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我收到此错误
java.lang.ClassCastException: android.graphics.Bitmap cannot be cast to androidx.compose.ui.graphics.ImageBitmap
Run Code Online (Sandbox Code Playgroud) 我想使用 jetpack compose 开发一个浮动可拖动按钮,我还需要知道用户拖动交互何时开始以及何时结束。
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center,
content = {
val interactionSource = remember { MutableInteractionSource() }
val interactions = remember { mutableStateListOf<Interaction>() }
LaunchedEffect(interactionSource) {
interactionSource.interactions.collect { interaction ->
Log.i("dragInteraction", "-> $interaction")
}
}
var offsetX by remember { mutableStateOf(0f) }
var offsetY by remember { mutableStateOf(0f) }
Surface(
modifier = Modifier
.offset {
IntOffset(
x = offsetX.roundToInt(),
y = offsetY.roundToInt()
)
}
.size(60.dp)
.pointerInput(Unit) {
detectDragGestures { change, dragAmount ->
offsetX += dragAmount.x
offsetY …Run Code Online (Sandbox Code Playgroud)