Open xihan123 opened 1 year ago
测试后是没问题的,我提供了以下示例,以供参考:
/*
* Copyright lt 2022
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.lt.common_app
import M
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.*
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.lt.common_app.base.BaseComposeActivity
import com.lt.compose_views.compose_pager.ComposePager
import com.lt.compose_views.compose_pager.ComposePagerState
import com.lt.compose_views.other.FpsText
import com.lt.compose_views.pager_indicator.TextPagerIndicator
/**
* creator: lt 2022/10/22 lt.dygzs@qq.com
* effect :
* warning:
*/
class TextPagerIndicatorActivity : BaseComposeActivity() {
private val colors = mutableStateListOf(
Color(150, 105, 61, 255) to "暴走",
Color.DarkGray to "十字斩",
Color(122, 138, 55, 255) to "崩山击",
Color(114, 61, 101, 255) to "崩山裂地斩",
Color.Gray to "怒气爆发",
Color(112, 62, 11, 255) to "嗜魂封魔斩",
Color(50, 134, 74, 255) to "噬魂之手",
)
private val texts = colors.map { it.second }
private val pagerState = ComposePagerState()
private val textColor = Color(0xff999999)
private val selectTextColor = Color(0xff333333)
private val selectIndicatorColor = Color(0xff1773FC)
@Composable
override fun ComposeContent() {
val offsetPercent by remember { pagerState.createChildOffsetPercentFlow() }
.collectAsState(initial = 0f)
Column {
FpsText(modifier = M)
Button({ pagerState.setPageIndexWithAnimate(pagerState.getCurrSelectIndex() + 1) }) { Text("+1") }
Button({ pagerState.setPageIndexWithAnimate(pagerState.getCurrSelectIndex() + 2) }) { Text("+2") }
Button({ pagerState.setPageIndexWithAnimate(pagerState.getCurrSelectIndex() - 1) }) { Text("-1") }
Button({ pagerState.setPageIndexWithAnimate(pagerState.getCurrSelectIndex() - 2) }) { Text("-2") }
TextPagerIndicator(
texts = texts,
offsetPercentWithSelect = offsetPercent,
selectIndex = pagerState.getCurrSelectIndex(),
fontSize = 16.sp,
selectFontSize = 20.sp,
textColor = textColor,
selectTextColor = selectTextColor,
selectIndicatorColor = selectIndicatorColor,
onIndicatorClick = {
pagerState.setPageIndexWithAnimate(it)
},
modifier = M
.fillMaxWidth()
.height(35.dp),
margin = 28.dp,
)
ComposePager(
pageCount = colors.size,
modifier = M.fillMaxSize(),
composePagerState = pagerState,
orientation = Orientation.Horizontal,
) {
Box(
modifier = M
.fillMaxSize()
.background(colors[index].first)
)
}
}
}
}
ps:视频链接打不开emmm
ps:视频链接打不开emmm
screen-20221205-230212.mp4 https://www.aliyundrive.com/s/Mrv8Uw8Cdis
哦哦,你是只使用TextPagerIndicator时产生的这个问题是吧,我这边修改一下
是因为我在 Flow 里面使用的原因吗 监听了懒加载垂直网格的可见项 然后根据可见项来 setPageIndex
目前TextPagerIndicator的自动滑动是依赖于offsetPercentWithSelect这个参数的,只改变selectIndex的话目前是没有自动滑动功能 如果你是修改composePager的state来驱动TextPagerIndicator的话,可以使用setPageIndexWithAnimate方法
ps:旧版本setPageIndexWithAnimate方法只能一页一页的切,我可以发一个版本让其一次切换多页
滑稍微快一点就会无反应,原来只能一页一页切的吗,切换多页就拜托你啦
你试一下1.3.4.1版本
你试一下1.3.4.1版本
虽然反应慢一些,感觉可用了,我也说不上哪里怪怪的(是因为debug版本的原因吗) compose 视频演示:https://www.aliyundrive.com/s/qb2xWvxHyzm 想要达到的 adapter 的效果: https://www.aliyundrive.com/s/36dQUcXzirS
看着慢的不太正常,我查查是不是代码问题,你可以打印一下collect中的值看看频率对不对
频率没啥问题 打包成发布版好多了:https://www.aliyundrive.com/s/u85dbV7om4R 还是有一定概率会反应不过来,看日志和性能都没啥问题,应该是优化还不够吧
那就好,后续抽空我再优化下
那就好,后续抽空我再优化下
谢谢你的回复啦
谢谢你的反馈和使用
还有一个问题 如果点的太快 会触发索引异常或者以下异常
补充一下 使用的是 setPageIndexWithAnimate 方法
setPageIndex 没有此问题
java.lang.ArrayIndexOutOfBoundsException: length=21; index=23 at com.lt.compose_views.pager_indicator.IndicatorsInfo.getIndicatorEnd-impl(IndicatorsInfo.kt:47) at com.lt.compose_views.pager_indicator.IndicatorsInfo.getIndicatorSize-impl(IndicatorsInfo.kt:55) at com.lt.compose_views.pager_indicator.TextPagerIndicatorKt$TextPagerIndicator$1.invoke(TextPagerIndicator.kt:105) at com.lt.compose_views.pager_indicator.TextPagerIndicatorKt$TextPagerIndicator$1.invoke(TextPagerIndicator.kt:100) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at com.lt.compose_views.pager_indicator.PagerIndicatorKt.PagerIndicator-V-95POc(PagerIndicator.kt:99) at com.lt.compose_views.pager_indicator.TextPagerIndicatorKt.TextPagerIndicator--cTi5qY(TextPagerIndicator.kt:154) at com.lt.compose_views.pager_indicator.TextPagerIndicatorKt.TextPagerIndicator-W5nztNM(TextPagerIndicator.kt:91) at cn.xihan.age.ui.main.home.HomeScreenKt$HomeScreen$1$1$2$2$1$1.invoke(HomeScreen.kt:132) at cn.xihan.age.ui.main.home.HomeScreenKt$HomeScreen$1$1$2$2$1$1.invoke(HomeScreen.kt:131) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116) at androidx.compose.runtime.internal.ComposableLambdaImpl$invoke$1.invoke(ComposableLambda.jvm.kt:127) at androidx.compose.runtime.internal.ComposableLambdaImpl$invoke$1.invoke(ComposableLambda.jvm.kt:127) at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:145) at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2375) at androidx.compose.runtime.ComposerImpl.skipToGroupEnd(Composer.kt:2666) at androidx.compose.material3.CardKt.Card(Card.kt:95) at cn.xihan.age.ui.main.home.HomeScreenKt$HomeScreen$1$1$2$2$1.invoke(HomeScreen.kt:126) at cn.xihan.age.ui.main.home.HomeScreenKt$HomeScreen$1$1$2$2$1.invoke(HomeScreen.kt:125) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.foundation.lazy.LazyListScopeImpl$item$3.invoke(LazyListScopeImpl.kt:56) at androidx.compose.foundation.lazy.LazyListScopeImpl$item$3.invoke(LazyListScopeImpl.kt:56) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:135) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.foundation.lazy.LazyListItemProviderImpl$1.invoke(LazyListItemProvider.kt:80) at androidx.compose.foundation.lazy.LazyListItemProviderImpl$1.invoke(LazyListItemProvider.kt:79) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:135) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.foundation.lazy.layout.DefaultLazyLayoutItemsProvider.Item(LazyLayoutItemProvider.kt:118) at androidx.compose.foundation.lazy.LazyListItemProviderImpl.Item(Unknown Source:76) at androidx.compose.foundation.lazy.layout.DefaultDelegatingLazyLayoutItemProvider.Item(LazyLayoutItemProvider.kt:197) at androidx.compose.foundation.lazy.LazyListItemProviderKt$rememberLazyListItemProvider$1$1.Item(Unknown Source:27) at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactory$CachedItemContent$createContentLambda$1$1.invoke(LazyLayoutItemContentFactory.kt:99) at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactory$CachedItemContent$createContentLambda$1$1.invoke(LazyLayoutItemContentFactory.kt:98) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) 16:57:34.000 E at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228) at androidx.compose.runtime.saveable.SaveableStateHolderImpl.SaveableStateProvider(SaveableStateHolder.kt:84) at androidx.compose.foundation.lazy.layout.LazySaveableStateHolder.SaveableStateProvider(LazySaveableStateHolder.kt:84) at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactory$CachedItemContent$createContentLambda$1.invoke(LazyLayoutItemContentFactory.kt:98) at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactory$CachedItemContent$createContentLambda$1.invoke(LazyLayoutItemContentFactory.kt:90) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$subcompose$2$1$1.invoke(SubcomposeLayout.kt:771) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$subcompose$2$1$1.invoke(SubcomposeLayout.kt:448) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:78) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3248) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3238) at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341) at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1) at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3238) at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3173) at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:587) at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:950) at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3848) at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3848) at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3848) at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3848) at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:519) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcomposeInto(SubcomposeLayout.kt:468) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:441) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:432) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:421) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$Scope.subcompose(SubcomposeLayout.kt:733) at androidx.compose.foundation.lazy.layout.LazyLayoutMeasureScopeImpl.measure-0kLqBqw(LazyLayoutMeasureScope.kt:118) at androidx.compose.foundation.lazy.LazyMeasuredItemProvider.getAndMeasure-ZjPyQlc(LazyMeasuredItemProvider.kt:47) at androidx.compose.foundation.lazy.LazyListMeasureKt.measureLazyList-nXYdgZc(LazyListMeasure.kt:154) at androidx.compose.foundation.lazy.LazyListKt$rememberLazyListMeasurePolicy$1$1.invoke-0kLqBqw(LazyList.kt:300) at androidx.compose.foundation.lazy.LazyListKt$rememberLazyListMeasurePolicy$1$1.invoke(LazyList.kt:191) at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$1$2$1.invoke-0kLqBqw(LazyLayout.kt:71) at androidx.compose.foundation.lazy.layout.LazyLayoutKt$LazyLayout$1$2$1.invoke(LazyLayout.kt:69) at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy$1.measure-3p2s80s(SubcomposeLayout.kt:591) 16:57:34.000 E at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:103) at androidx.compose.foundation.AndroidOverscrollKt$StretchOverscrollNonClippingLayer$2.invoke-3p2s80s(AndroidOverscroll.kt:580) at androidx.compose.foundation.AndroidOverscrollKt$StretchOverscrollNonClippingLayer$2.invoke(AndroidOverscroll.kt:579) at androidx.compose.ui.layout.LayoutModifierImpl.measure-3p2s80s(LayoutModifier.kt:285) at androidx.compose.ui.node.BackwardsCompatNode.measure-3p2s80s(BackwardsCompatNode.kt:343) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:155) at androidx.compose.foundation.AndroidOverscrollKt$StretchOverscrollNonClippingLayer$1.invoke-3p2s80s(AndroidOverscroll.kt:564) at androidx.compose.foundation.AndroidOverscrollKt$StretchOverscrollNonClippingLayer$1.invoke(AndroidOverscroll.kt:563) at androidx.compose.ui.layout.LayoutModifierImpl.measure-3p2s80s(LayoutModifier.kt:285) at androidx.compose.ui.node.BackwardsCompatNode.measure-3p2s80s(BackwardsCompatNode.kt:343) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:155) at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier.measure-3p2s80s(GraphicsLayerModifier.kt:405) at androidx.compose.ui.node.BackwardsCompatNode.measure-3p2s80s(BackwardsCompatNode.kt:343) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:155) at androidx.compose.foundation.layout.PaddingValuesModifier.measure-3p2s80s(Padding.kt:417) at androidx.compose.ui.node.BackwardsCompatNode.measure-3p2s80s(BackwardsCompatNode.kt:343) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:155) at androidx.compose.foundation.layout.FillModifier.measure-3p2s80s(Size.kt:658) at androidx.compose.ui.node.BackwardsCompatNode.measure-3p2s80s(BackwardsCompatNode.kt:343) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:155) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1077) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1073) at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2139) at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:130) at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:126) at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341) at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1) at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:126) at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:120) at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:107) at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1073) at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:36) at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:341) at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release(LayoutNode.kt:1135) at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release$default(LayoutNode.kt:1126) at androidx.compose.ui.node.MeasureAndLayoutDelegate.doRemeasure-sdFAvZA(MeasureAndLayoutDelegate.kt:309) at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:434) 16:57:34.000 E at androidx.compose.ui.node.MeasureAndLayoutDelegate.access$remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:39) at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout(MeasureAndLayoutDelegate.kt:330) at androidx.compose.ui.platform.AndroidComposeView.measureAndLayout(AndroidComposeView.android.kt:774) at androidx.compose.ui.node.Owner.measureAndLayout$default(Owner.kt:216) at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:999) at android.view.View.draw(View.java:23198) at android.view.View.updateDisplayListIfDirty(View.java:22062) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4513) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4486) at android.view.View.updateDisplayListIfDirty(View.java:22018) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4513) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4486) at android.view.View.updateDisplayListIfDirty(View.java:22018) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4513) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4486) at android.view.View.updateDisplayListIfDirty(View.java:22018) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4513) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4486) at android.view.View.updateDisplayListIfDirty(View.java:22018) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:682) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:688) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:786) at android.view.ViewRootImpl.draw(ViewRootImpl.java:4579) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4290) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3517) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2286) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8952) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1231) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1239) at android.view.Choreographer.doCallbacks(Choreographer.java:899) at android.view.Choreographer.doFrame(Choreographer.java:832) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1214) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7893) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
我瞅瞅
你试试1.3.5解决了没,前两天jitpack崩了,导致没法打包...
你试试1.3.5解决了没,前两天jitpack崩了,导致没法打包...
闪退问题解决了 但是你看看release版的这个造型对不对?感觉怪怪的 视频地址:https://www.aliyundrive.com/s/zwepjTECQc6
感觉像是你的数据加载的比较慢导致的,数据不是缓存的是实时获取(实时计算)的吗?实在不行的话你可以将pageCache调大一点
感觉像是你的数据加载的比较慢导致的,数据不是缓存的是实时获取(实时计算)的吗?实在不行的话你可以将pageCache调大一点
是缓存的,由 viewModel 持有 现在的问题就是感觉"噔噔"两下才移动过去 不够连贯
看着像是没有做动画(或者动画卡了),我这边测的是有动画的,目前动画是先直接跳到index-1的位置,然后从index-1动画过渡到index 你这个有可复现的示例吗?
看着像是没有做动画(或者动画卡了),我这边测的是有动画的,目前动画是先直接跳到index-1的位置,然后从index-1动画过渡到index 你这个有可复现的示例吗?
这几天出现症状 没有力气去开电脑 你能录屏看看你的是什么效果吗
看着像是没有做动画(或者动画卡了),我这边测的是有动画的,目前动画是先直接跳到index-1的位置,然后从index-1动画过渡到index 你这个有可复现的示例吗?
这是我项目里使用的方法
TextPagerIndicator(
texts = weekList,
offsetPercentWithSelect = offsetPercent,
fontSize = 15.sp,
selectFontSize = 20.sp,
selectIndex = pagerState.getCurrSelectIndex(),
textColor = MaterialTheme.colorScheme.onSurface,
selectTextColor = MaterialTheme.colorScheme.primary,
selectIndicatorColor = MaterialTheme.colorScheme.primary,
onIndicatorClick = {
if (pagerState.getCurrSelectIndex() != it) {
pagerState.setPageIndexWithAnimate(it)
}
},
modifier = M
.wrapContentSize()
.padding(10.dp),
margin = 22.dp,
userCanScroll = true
)
`
ComposePager和offsetPercent部分的也发一下吧
ComposePager和offsetPercent部分的也发一下吧
val pagerState = rememberComposePagerState()
val offsetPercent by remember { pagerState.createChildOffsetPercentFlow() }
.collectAsState(initial = 0f)
ComposePager(
pageCount = weekList.size,
modifier = M
.size(0.dp)
.padding(10.dp),
composePagerState = pagerState,
orientation = Orientation.Horizontal,
) {
}
你的测试机的开发者选项里,过度动画和Animator的动画时长有改吗?
你的测试机的开发者选项里,过度动画和Animator的动画时长有改吗?
都是默认的
好吧,我试了下都关了和你发的视频很类似,那我再找找是什么原因
你引用这个库试一下,看看还有没有问题了 "androidx.compose.material:animation:$composeVersion"
你引用这个库试一下,看看还有没有问题了 "androidx.compose.material:animation:$composeVersion"
一直有引用这个库阿
好吧
使用 pagerState.setPageIndex(it) TextPagerIndicator 不会自动翻页 是我写法的问题吗 虽然选中了但是不翻页。。。
ComposePager 的滚动翻页正常
演试视频地址:https://pdsapi.aliyundrive.com/v2/redirect?spm=aliyundrive.file_file_sharing.0.0.7ecd3575vsX7dJ&id=d66c63022f70498d8b987be496b0ebb01670253945123504484