Android透明边缘图像滑块

时间:2018-09-29 11:15:56

标签: android image android-layout slider android-viewflipper

我一直在尝试重新创建如图所示的图像滑块。寻找了很多图像滑块/ Flipper库。但是最后,我可以看到每个滑块在滑块底部都有某种灰色叠加效果。如何删除滑块描述布局中的效果?
还有其他更好的库提供与示例滑块相同的功能吗?

主要活动::

  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    context = MainActivity.this;

    ToolbarInit();
    BottombarInit();
    ModelItems();
    ListHandler();

    sliderLayout = findViewById(R.id.imageSlider);
    sliderLayout.setIndicatorAnimation(SliderLayout.Animations.SCALE); 
    sliderLayout.setScrollTimeInSec(8); //set scroll delay in seconds :
     setSliderViews();
}

private void setSliderViews() {

    for (int i = 0; i <= 4; i++) {

        SliderView sliderView = new SliderView(this);

        switch (i) {
            case 0:
                sliderView.setImageDrawable(R.drawable.slider1);
                break;
            case 1:
                sliderView.setImageDrawable(R.drawable.slider2);
                break;
            case 2:
                sliderView.setImageDrawable(R.drawable.slider3);
                break;
            case 3:
                sliderView.setImageDrawable(R.drawable.slider4);
                break;
            case 4:
                sliderView.setImageDrawable(R.drawable.slider5);
                break;
        }

        sliderView.setImageScaleType(ImageView.ScaleType.FIT_XY);
        sliderView.setDescription("");
        //sliderView.setDescription("setDescription " + (i + 1));
        final int finalI = i;
        sliderView.setOnSliderClickListener(new 
        SliderView.OnSliderClickListener() {
            @Override
            public void onSliderClick(SliderView sliderView) {
                Toast.makeText(MainActivity.this, "This is slider " + (finalI + 1), Toast.LENGTH_SHORT).show();
            }
        });

        //at last add this view in your layout :
        sliderLayout.addSliderView(sliderView);
    }
}
  

XML ::

 <com.smarteist.autoimageslider.SliderLayout
            android:id="@+id/imageSlider"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_alignParentTop="true"
            android:focusableInTouchMode="true"
            android:theme="@style/AppTheme.TranslucentStatusBar"
            app:indicator_visibility="visible"/>
  

示例图像滑块

enter image description here

0 个答案:

没有答案