Mau*_*ker 42 android imageview android-drawable picasso android-glide
我正在编写一个Android应用程序,它应该有一个"幻灯片"功能.我发现这个漂亮的图书馆,基于毕加索,完全符合我的要求,而且大多数时候它都运行得很好.
问题是,有时我的图像没有加载到幻灯片中ImageView...它只显示一个"黑色画布",你可以在下面的截图中看到.
我从我的drawables加载本地资源的图像.有时它会在纵向模式下发生,有时在横向模式下发生.我使用哪个图像并不重要,有时会发生"黑度".
编辑:
我正在使用Android 5.0.2和4.4.2 - 它似乎不会发生在4.4.2上.仅在5.0.2.
它发生在带有Android 5.1的Moto X 2014上.
我试图加载的图像在磁盘上有45KB,分辨率为900x445.
我按照建议打开了布局,这些是结果:
它在滚动上保持这样.
有时,它会变成白色而不是黑色(或白色,然后是黑色).
我试过的其他东西:res/drawable当我将文件从该文件夹更改res/drawable-xxxhdpi为5.0.2设备上的滑块时,我的drawables位于文件夹中.跆拳道???
我尝试了不同的图像,在幻灯片上加载多个图像,甚至这个拉取请求将Picasso更改为在lib上滑动.似乎没有任何作用,错误似乎是随机的.
一旦我尝试使用来自网络的URL而不是本地存储上的实际drawable,它就可以工作了.与完全相同的图像.
这是我加载图像的方式:
Fragment.java
private SliderLayout slider;
private PagerIndicator indicator;
// ...
private void setupSlider() {
HashMap<String,Integer> file_maps = new HashMap<>();
file_maps.put("Blah",R.drawable.banner_1);
file_maps.put("Bleh",R.drawable.banner_2);
file_maps.put("Blih",R.drawable.banner_3);
file_maps.put("Bloh",R.drawable.banner_4);
for (String name : file_maps.keySet()) {
DefaultSliderView dsv = new DefaultSliderView(getActivity());
dsv.description(name)
.image(file_maps.get(name))
.error(R.drawable.banner_error)
.empty(R.drawable.empty)
.setScaleType(BaseSliderView.ScaleType.Fit)
.setOnSliderClickListener(this);
//add your extra information
dsv.bundle(new Bundle());
dsv.getBundle()
.putString("extra",name);
slider.addSlider(dsv);
}
slider.setPresetTransformer(SliderLayout.Transformer.Default);
slider.setCustomIndicator(indicator);
slider.setCustomAnimation(new DescriptionAnimation());
slider.setDuration(4000);
slider.addOnPageChangeListener(this);
}
Run Code Online (Sandbox Code Playgroud)
fragment.xml之
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:custom="http://schemas.android.com/apk/res-auto"
tools:context="com.example.fragments.Fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sv_main">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rl_main">
<com.daimajia.slider.library.SliderLayout
android:id="@+id/slider"
android:layout_width="match_parent"
android:layout_height="200dp"
/>
<com.daimajia.slider.library.Indicators.PagerIndicator
android:id="@+id/custom_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/slider"
custom:shape="oval"
custom:selected_color="#00BFA5"
custom:unselected_color="#55333333"
custom:selected_padding_left="@dimen/spacing_medium"
custom:selected_padding_right="@dimen/spacing_medium"
custom:selected_padding_top="3dp"
custom:selected_padding_bottom="@dimen/spacing_small"
custom:unselected_padding_left="@dimen/spacing_medium"
custom:unselected_padding_right="@dimen/spacing_medium"
custom:unselected_padding_top="@dimen/spacing_small"
custom:unselected_padding_bottom="4dp"
custom:selected_width="@dimen/spacing_medium"
custom:selected_height="@dimen/spacing_medium"
custom:unselected_width="6dp"
custom:unselected_height="6dp"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/custom_indicator"
android:id="@+id/ll_main_body">
</LinearLayout>
</RelativeLayout>
</ScrollView>
<!-- Other stuff -->
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我正在关注libs wiki页面上的教程.并且LogCat上没有任何错误,这使得解决这个问题变得更加困难.
有任何想法吗?
| 归档时间: |
|
| 查看次数: |
2877 次 |
| 最近记录: |