如何更改图像指示器背景颜色:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<com.daimajia.slider.library.SliderLayout
android:id="@+id/slider"
android:background="#133"
android:layout_width="match_parent"
android:layout_height="130dp"
/>
</LinearLayout>
java代码:
sliderShow = (SliderLayout) findViewById(R.id.slider);
TextSliderView textSliderView = new TextSliderView(this);
textSliderView.image(file_maps.get(name));
sliderShow.addSlider(textSliderView);
答案 0 :(得分:1)
在 RelativeLayout
中的xml中的 SliderLayout 之后添加 PagerIndicator<com.daimajia.slider.library.SliderLayout
android:id="@+id/banner_slider"
android:layout_width="match_parent"
android:layout_height="match_parent"
custom:indicator_visibility="visible"
custom:auto_cycle="true" />
<com.daimajia.slider.library.Indicators.PagerIndicator
android:id="@+id/banner_slider_indicator"
android:layout_width="match_parent"
android:layout_height="30dp"
app:selected_color="@color/colorAccent"
app:unselected_color="@color/iconsLight"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:background="@color/dividerDark"
style="@style/AndroidImageSlider_Indicator" />
<强>风格=&#34; @风格/ AndroidImageSlider_Indicator&#34; 强>
<style name="AndroidImageSlider_Indicator">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:gravity">center</item>
<item name="android:paddingLeft">2dp</item>
<item name="android:paddingRight">2dp</item>
<item name="shape">oval</item>
<item name="padding_left">3dp</item>
<item name="padding_right">3dp</item>
<item name="padding_top">4dp</item>
<item name="padding_bottom">4dp</item>
<item name="selected_width">8dp</item>
<item name="selected_height">8dp</item>
<item name="unselected_width">6dp</item>
<item name="unselected_height">6dp</item>
</style>
Java代码
SliderLayout sliderLayout = (SliderLayout) rootView.findViewById(R.id.banner_slider);
PagerIndicator pagerIndicator = (PagerIndicator) rootView.findViewById(R.id.banner_slider_indicator);
DefaultSliderView defaultSliderView = new DefaultSliderView(getContext());
defaultSliderView
.description(name)
.image(slider_covers.get(name))
.setScaleType(BaseSliderView.ScaleType.Fit);
sliderLayout.addSlider(defaultSliderView);
sliderLayout.setCustomIndicator(pagerIndicator);
答案 1 :(得分:0)
你要试试吗?
textSliderView.getView().findViewById(R.id.description_layout).setBackgroundColor(<your_color>);