我想在我的 Android 应用程序中使用图像幻灯片。 所以,我使用daimajia库。( https://github.com/daimajia/AndroidImageSlider )
我必须保持图像的比例像这样。
<ImageView
android:id="@+id/main_function01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@mipmap/img_app_function_02" />
但是,当我使用daimajia库的SliderLayout时,它不起作用。
<com.daimajia.slider.library.SliderLayout
android:id="@+id/slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
custom:auto_cycle="true"
custom:indicator_visibility="visible"
custom:pager_animation="Accordion"
custom:pager_animation_span="1100" />
我该怎么办?或者还有其他最好的方法吗?
最佳答案
您必须在添加到 slider 时为每个图像设置它:
TextSliderView textSliderView = new TextSliderView(context);
textSliderView
.setScaleType(BaseSliderView.ScaleType.CenterCrop)
.image(url);
mSlider.addSlider(textSliderView);
它可以是 Fit、CenterCrop 或 CenterInside:
关于android - 我想使用 android daimajia sliderLayout 保持图像比例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37341605/