We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
需求:指示器要先隐藏,然后根据左滑右滑让指示器显示 代码: 1、 binding.viewpagerImage.setAdapter(imageListAdapter).setAutoPlay(false).setCanLoop(true) .setIndicatorSlideMode(IndicatorSlideMode.NORMAL).setIndicatorVisibility(View.VISIBLE) .setIndicatorGravity(IndicatorGravity.END).setInterval(4000).setScrollDuration(300) .setIndicatorView(FigureIndicatorView(parent.context).apply { setRadius(DimenUtils.dpi2pxi(18)) setTextSize(DimenUtils.dpi2pxi(12)) setTextColor(Color.WHITE) setBackgroundColor(Color.parseColor("#80000000")) }).create() 2、 binding.viewpagerImage.setIndicatorVisibility(View.GONE) 测试: 发现指示器仍然可见,并没有隐藏 解决: 和作者沟通,可先暂时用反射来控制隐藏显示,以下是可用的代码 kotlin.runCatching { Timber.d("showImageIndicator:${show}") val bannerClazz: Class<*> = Class.forName("com.zhpan.bannerview.BannerViewPager") val indicatorLayoutField = bannerClazz.getDeclaredField("mIndicatorLayout") indicatorLayoutField.isAccessible = true val mIndicatorLayout = indicatorLayoutField.get(binding.viewpagerImage) as RelativeLayout val setVisibilityValue = if (show) View.VISIBLE else View.GONE if (mIndicatorLayout.visibility == setVisibilityValue){ return } val viewClazz: Class<*> = mIndicatorLayout.javaClass val setVisibilityMethod: Method = viewClazz.getMethod("setVisibility", Int::class.javaPrimitiveType) setVisibilityMethod.invoke(mIndicatorLayout, setVisibilityValue) }.onFailure { Timber.d("set Indicator setVisibility failed") }
binding.viewpagerImage.setAdapter(imageListAdapter).setAutoPlay(false).setCanLoop(true) .setIndicatorSlideMode(IndicatorSlideMode.NORMAL).setIndicatorVisibility(View.VISIBLE) .setIndicatorGravity(IndicatorGravity.END).setInterval(4000).setScrollDuration(300) .setIndicatorView(FigureIndicatorView(parent.context).apply { setRadius(DimenUtils.dpi2pxi(18)) setTextSize(DimenUtils.dpi2pxi(12)) setTextColor(Color.WHITE) setBackgroundColor(Color.parseColor("#80000000")) }).create()
binding.viewpagerImage.setIndicatorVisibility(View.GONE)
kotlin.runCatching { Timber.d("showImageIndicator:${show}") val bannerClazz: Class<*> = Class.forName("com.zhpan.bannerview.BannerViewPager") val indicatorLayoutField = bannerClazz.getDeclaredField("mIndicatorLayout") indicatorLayoutField.isAccessible = true val mIndicatorLayout = indicatorLayoutField.get(binding.viewpagerImage) as RelativeLayout val setVisibilityValue = if (show) View.VISIBLE else View.GONE if (mIndicatorLayout.visibility == setVisibilityValue){ return } val viewClazz: Class<*> = mIndicatorLayout.javaClass val setVisibilityMethod: Method = viewClazz.getMethod("setVisibility", Int::class.javaPrimitiveType) setVisibilityMethod.invoke(mIndicatorLayout, setVisibilityValue) }.onFailure { Timber.d("set Indicator setVisibility failed") }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
需求:指示器要先隐藏,然后根据左滑右滑让指示器显示
代码:
1、
binding.viewpagerImage.setAdapter(imageListAdapter).setAutoPlay(false).setCanLoop(true) .setIndicatorSlideMode(IndicatorSlideMode.NORMAL).setIndicatorVisibility(View.VISIBLE) .setIndicatorGravity(IndicatorGravity.END).setInterval(4000).setScrollDuration(300) .setIndicatorView(FigureIndicatorView(parent.context).apply { setRadius(DimenUtils.dpi2pxi(18)) setTextSize(DimenUtils.dpi2pxi(12)) setTextColor(Color.WHITE) setBackgroundColor(Color.parseColor("#80000000")) }).create()
2、
binding.viewpagerImage.setIndicatorVisibility(View.GONE)
测试:
发现指示器仍然可见,并没有隐藏
解决:
和作者沟通,可先暂时用反射来控制隐藏显示,以下是可用的代码
kotlin.runCatching { Timber.d("showImageIndicator:${show}") val bannerClazz: Class<*> = Class.forName("com.zhpan.bannerview.BannerViewPager") val indicatorLayoutField = bannerClazz.getDeclaredField("mIndicatorLayout") indicatorLayoutField.isAccessible = true val mIndicatorLayout = indicatorLayoutField.get(binding.viewpagerImage) as RelativeLayout val setVisibilityValue = if (show) View.VISIBLE else View.GONE if (mIndicatorLayout.visibility == setVisibilityValue){ return } val viewClazz: Class<*> = mIndicatorLayout.javaClass val setVisibilityMethod: Method = viewClazz.getMethod("setVisibility", Int::class.javaPrimitiveType) setVisibilityMethod.invoke(mIndicatorLayout, setVisibilityValue) }.onFailure { Timber.d("set Indicator setVisibility failed") }
The text was updated successfully, but these errors were encountered: