我正在使用GlideSlider(https://github.com/firdausmaulan/GlideSlider)在我的应用中创建图像滑块。我正在使用该作者(https://github.com/firdausmaulan/GlideSlider-Example)的示例,但面临两个问题。
MainActivity ::
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDemoSlider = findViewById(R.id.slider);
ArrayList<String> listUrl = new ArrayList<>();
ArrayList<String> listName = new ArrayList<>();
HashMap<String,Integer> file_maps = new HashMap<String, Integer>();
file_maps.put("Hannibal",R.drawable.slider1);
file_maps.put("Big Bang Theory",R.drawable.slider2);
file_maps.put("House of Cards",R.drawable.slider3);
file_maps.put("Game of Thrones", R.drawable.slider4);
for(String name : file_maps.keySet()){
TextSliderView textSliderView = new TextSliderView(this);
// initialize a SliderLayout
textSliderView
.description(name)
.image(file_maps.get(name))
.setOnSliderClickListener(this);
//add your extra information
textSliderView.bundle(new Bundle());
textSliderView.getBundle()
.putString("extra",name);
mDemoSlider.addSlider(textSliderView);
}
mDemoSlider.setPresetTransformer(SliderLayout.Transformer.Default);
mDemoSlider.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);
mDemoSlider.setCustomAnimation(new DescriptionAnimation());
mDemoSlider.setDuration(4000);
mDemoSlider.addOnPageChangeListener(this);
}
XML文件::
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.glide.slider.example.MainActivity">
<com.glide.slider.library.SliderLayout
android:id="@+id/slider"
android:layout_width="match_parent"
android:layout_height="200dp" />
注意::还有其他我可以轻松使用的图像滑块库吗?