我想为我的项目制作图像滑块,而不是使用这个库https://github.com/smarteist/android-image-slider。
但是当我复制并粘贴代码在我MainActivity的动画里面(SliderLayout.Animations.FILL)是红色的?
public class MainActivity extends AppCompatActivity {
SliderLayout sliderLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sliderLayout = findViewById(R.id.imageSlider);
sliderLayout.setIndicatorAnimation(SliderLayout.Animations.FILL); //set indicator animation by using SliderLayout.Animations. :WORM or THIN_WORM or COLOR or DROP or FILL or NONE or SCALE or SCALE_DOWN or SLIDE and SWAP!!
sliderLayout.setScrollTimeInSec(1); //set scroll delay in seconds :
setSliderViews();
}
private void setSliderViews() {
for (int i = 0; i <= 3; i++) {
SliderView sliderView = new SliderView(this);
switch (i) {
case 0:
sliderView.setImageUrl("https://images.pexels.com/photos/547114/pexels-photo-547114.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260");
break;
case 1:
sliderView.setImageUrl("https://images.pexels.com/photos/218983/pexels-photo-218983.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260");
break;
case 2:
sliderView.setImageUrl("https://images.pexels.com/photos/747964/pexels-photo-747964.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260");
break;
case 3:
sliderView.setImageUrl("https://images.pexels.com/photos/929778/pexels-photo-929778.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260");
break;
}
}
}
犯罪嫌疑人X
RISEBY
相关分类