Getting a black ImageView using Picasso and Glide

Problem

I am writing an Android application that should have a Slideshow feature. I found this pretty Picasso-based library that does exactly what I wanted, and it worked great most of the time.

The problem is that my images do not load into the ImageView slide ... It only shows a “black canvas”, as you can see in the screenshot below.

enter image description here

I am loading an image from a local resource from my drawings. Sometimes this happens in portrait mode, sometimes in landscape mode. It doesn’t matter which image I use, sometimes blackness occurs.

EDIT: I am using Android 5.0.2 and 4.4.2. This does not seem to happen in 4.4.2. Only on 5.0.2.

Second edit: This happened on the Moto X 2014 with android 5.1.

Third edit: The images I'm trying to upload have 45 KB on a disc with a resolution of 900x445.

However, another edit: I turned on the layout as suggested, and these were the results:

Single slide

And this happens in the scroll.

enter image description here

And sometimes it becomes white, not black (or white, then black).

enter image description here

Something else I tried: My drawings were located in the res/drawable folder when I changed the files from this folder to the res/drawable-xxxhdpi slider running on device 5.0.2, WTF ??? affairs>

What have i tried so far

I tried different images, uploaded several images on a slide, and even this stretch request that changes Picasso to Glide to lib, Nothing seems to work and the error seems random.

As soon as I tried to use the URLs from the Internet instead of the actual drawings in the local storage, it worked. With the same images.

This is how I upload images:

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); } 

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> 

I am following a tutorial from the wiki library. And there are no errors in LogCat, which makes it difficult to solve this problem.

Any ideas?

+42
android picasso android-drawable imageview android-glide
Nov 23 '15 at 4:35
source share
3 answers

Create a resource folder A named drawable-nodpi in this folder places your images instead of different folders or folders with the ability to move.

+1
Feb 22 '16 at 13:58
source share

Have you tried using ViewPager with ImageView and passing an array of image URIs to the adapter? I think that you can avoid / debug much better if you implement it yourself.

0
Dec 04 '15 at 16:30
source share

This library works great for me, the first time I used it. This is a really good library.

First

SliderLayout does not refer to anything. Where magic happens. Make an xml layout and access it using SliderLayout. After that, do not forget to call startAutoScroll () and in onPause () stopAutoScroll ().

https://github.com/daimajia/AndroidImageSlider/wiki/Start-Using

The link above is basically all you need.

Second

The problem may also be that it is inside scrollView. Scrolling callbacks may be incorrect.

Make a simple layout, start with a simple slider and work with the settings.

Good luck.

0
Jan 01 '15 at 4:05
source share



All Articles