1、添加库文件
dependencies { compile "com.android.support:support-v4:+" compile 'com.squareup.picasso:picasso:2.3.2' compile 'com.nineoldandroids:library:2.4.0' compile 'com.daimajia.slider:library:1.1.5@aar' }2、添加权限
<!-- if you want to load images from the internet --> <uses-permission android:name="android.permission.INTERNET" /> <!-- if you want to load images from a file OR from the internet --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />3、xml布局文件中
<com.daimajia.slider.library.SliderLayout android:id="@+id/slider" android:layout_width="match_parent" android:layout_height="200dp" />4、代码中找到id
SliderLayout sliderShow = (SliderLayout) findViewById(R.id.slider);5、操作具体控件
TextSliderView textSliderView = new TextSliderView(this); textSliderView .description("Game of Thrones") .image("http://images.boomsbeat.com/data/images/full/19640/game-of-thrones-season-4-jpg.jpg"); sliderShow.addSlider(textSliderView);
@Override protected void onStop() { sliderShow.stopAutoCycle(); super.onStop(); }