我尝试在android-studio中创建滑块显示
我的代码在API 26中成功运行
但在API 28中不起作用
我的代码是:
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'
}
并添加到清单
<!-- 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" />
然后将滑块添加到布局:
<com.daimajia.slider.library.SliderLayout
android:id="@+id/slider"
android:layout_width="match_parent"
android:layout_height="200dp"
/>
通过调用findViewById获取SliderLayout实例:
SliderLayout sliderShow = (SliderLayout) findViewById(R.id.slider);
extSliderView textSliderView = new TextSliderView(this);
textSliderView
.description("Game of Thrones")
.image("http://s8.picofile.com/file/8368745750/Blue_hills.jpg");
sliderShow.addSlider(textSliderView);