如何解决Spotlight 无法正确点亮 NestedScrollView 内的组件
我使用此 Spotlight 库在我的应用中创建演练:https://github.com/TakuSemba/Spotlight
一切正常,直到我尝试在 ViewPager 和 nestedScrollView 中使用聚光灯。
在这种情况下,当我点亮聚光灯内的第一个组件然后滚动到下一个组件时,我认为聚光灯会点亮下一个 Target(或我们的组件)的先前位置。请指导我如何解决这个问题?谢谢
这是我的聚光灯代码:
fun startFundSpotlight(
layoutInflater: LayoutInflater,activity: Activity,viewmodel: FundOverviewviewmodel
) {
val targets = ArrayList<Target>()
var spot: Spotlight? = null
val fundDetailsRoot = FrameLayout(activity.applicationContext)
val fundDetails =
layoutInflater.inflate(R.layout.layout_fund_otp_user_walkthrough,fundDetailsRoot)
val fundTarget = activity.findViewById<Button>(R.id.btn_fund_start)?.let {
Target.Builder()
.setAnchor(it)
.setShape(RoundedRectangle(it.height.toFloat(),it.width.toFloat(),65f,200))
.setoverlay(fundDetails)
.setonTargetListener(object : OnTargetListener {
override fun onStarted() {
val viewPager = activity.findViewById<ViewPager>(R.id.pagerFundWalkthrough)
val indicator = activity.findViewById<PagerIndicator>(R.id.pagerFundindicator)
viewPager.adapter =
OtpUserFundOverviewWalkthroughPagerAdapter(
activity.applicationContext
)
var current = 0
viewPager.addOnPagechangelistener(object : ViewPager.OnPagechangelistener {
override fun onPageScrolled(
position: Int,positionOffset: Float,positionOffsetPixels: Int
) {
}
override fun onPageSelected(position: Int) {
indicator.current = position
if (position in (current + 1)..1) {
viewmodel.isFundSpotlightPresented.postValue(true)
fundDetails.refreshDrawableState()
fundDetails.postInvalidate()
spot?.next()
} else if (current > position && position <= 1) {
spot?.prevIoUs()
viewmodel.isFundSpotlightViewPagerMovePrevIoUs.postValue(true)
}
current = position
}
override fun onPageScrollStateChanged(state: Int) {}
})
}
override fun onEnded() {
}
})
.build()
}
if (fundTarget != null) {
targets.add(fundTarget)
}
val fundChartTarget = activity.findViewById<FrameLayout>(R.id.fundChart)?.let {
Target.Builder()
.setAnchor(it)
.setShape(RoundedRectangle(it.height.toFloat(),5f,200))
.setoverlay(fundDetails)
.build()
}
if (fundChartTarget != null) {
targets.add(fundChartTarget)
}
spot = Spotlight.Builder(activity)
.setTargets(targets)
.setBackgroundColorRes(R.color.spotlightBackground)
.setDuration(200L)
.setAnimation(DecelerateInterpolator(2f))
.build()
spot.start()
val closeWalkthrough = View.OnClickListener {
spot.finish()
}
fundDetails.findViewById<View>(R.id.txt_fund_walkthrough_quick_help_stop)
.setonClickListener(closeWalkthrough)
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。