如何使用 com.glide.slider.library.SliderLayout 自定义指标样式?
How to customize Indicator styling with com.glide.slider.library.SliderLayout?
我有以下使用 this slider 的滑块布局:
<com.glide.slider.library.SliderLayout
android:id="@+id/slider_product_image"
android:layout_width="500dp"
android:layout_height="350dp"/>
<com.glide.slider.library.indicators.PagerIndicator
android:id="@+id/custom_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
app:selected_height="20dp"
app:selected_width="20dp"/>
这是我用来设置它的代码:
//Slider
for (item in prod.images) {
val sliderView = DefaultSliderView(context)
// initialize SliderLayout
sliderView
.image(item)
.setRequestOption(
RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.skipMemoryCache(true)
)
binding.sliderProductImage.addSlider(sliderView)
}
binding.sliderProductImage.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom)
binding.sliderProductImage.stopCyclingWhenTouch(false)
binding.sliderProductImage.stopAutoCycle()
滑块基于this one using picasso as image loader. The original slider allows for thorough indicator customization as can be seen here。有 app:selected_height
和 app:selected_width
等可用属性,它们应该设置所选项目指示器的高度和宽度,但它们对布局本身没有任何影响。这是我的结果图片:
选定的指标仍然是相同的大小。我错过了什么吗?有没有办法正确应用这些?
发现我的错误...一直在底部显示 you need to bind it with a SliderLayout instance 让它工作:
binding.sliderProductImage.setCustomIndicator(custom_indicator as PagerIndicator)
我有以下使用 this slider 的滑块布局:
<com.glide.slider.library.SliderLayout
android:id="@+id/slider_product_image"
android:layout_width="500dp"
android:layout_height="350dp"/>
<com.glide.slider.library.indicators.PagerIndicator
android:id="@+id/custom_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
app:selected_height="20dp"
app:selected_width="20dp"/>
这是我用来设置它的代码:
//Slider
for (item in prod.images) {
val sliderView = DefaultSliderView(context)
// initialize SliderLayout
sliderView
.image(item)
.setRequestOption(
RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.skipMemoryCache(true)
)
binding.sliderProductImage.addSlider(sliderView)
}
binding.sliderProductImage.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom)
binding.sliderProductImage.stopCyclingWhenTouch(false)
binding.sliderProductImage.stopAutoCycle()
滑块基于this one using picasso as image loader. The original slider allows for thorough indicator customization as can be seen here。有 app:selected_height
和 app:selected_width
等可用属性,它们应该设置所选项目指示器的高度和宽度,但它们对布局本身没有任何影响。这是我的结果图片:
选定的指标仍然是相同的大小。我错过了什么吗?有没有办法正确应用这些?
发现我的错误...一直在底部显示 you need to bind it with a SliderLayout instance 让它工作:
binding.sliderProductImage.setCustomIndicator(custom_indicator as PagerIndicator)