While loading image a thin line appears and the image is not visible while using fresco in a RecyclerView on Android Jellybean devices but the same works on KitKat+ devices.
Samsung - 4.1.1 - API 16 - 768 X 1280
SamsungGalaxyNote2 - 4.3 - API 18 - 720 X 1280
NOTE : Have tested in multiple devices and the scenario is the same
This is the way we are using it in the library
if (newsModelStoreList.get(position-1).getImageUrl() != null) {
String imageUrl = newsModelStoreList.get(position-1).getImageUrl();
String extension=".jpg";
try {
extension = imageUrl.substring(imageUrl.lastIndexOf("."));
}
catch (Exception e)
{
}
Log.d("extension: ",extension);
if(extension.equals(".gif")) {
Log.d("Detected Gif: ", "Starting gif controller");
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri(Uri.parse(imageUrl))
.setAutoPlayAnimations(true)
.build();
myHolder.newsImage.setController(controller);
}
else
{
myHolder.newsImage.setImageURI(Uri.parse(imageUrl));
}
}
I AM 100% SURE THAT URL IS AVAILABLE AND IS WORKING ON 4.4+ DEVICES
This is the news_layout.xml which gets inflated
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/feed_bg"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_parent_rounded_corner"
android:layout_marginTop="@dimen/feed_item_margin"
android:orientation="vertical"
android:paddingBottom="@dimen/feed_item_padding_top_bottom"
android:paddingTop="@dimen/feed_item_padding_top_bottom" >
<LinearLayout
android:layout_width="fill_parent"
android:gravity="right"
android:layout_height="wrap_content">
<TextView
android:id="@+id/timestamp"
android:gravity="right"
android:paddingRight="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="posted 5 min ago"
android:textColor="@color/timestamp"
android:textSize="@dimen/feed_item_timestamp" />
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/newsTitle"
android:textSize="22dp"
android:clickable="false"
android:textStyle="bold"
android:paddingLeft="@dimen/feed_item_status_pad_left_right"
android:paddingRight="@dimen/feed_item_status_pad_left_right"
android:textColor="@color/black"
android:textColorLink="@color/com_facebook_blue"
android:layout_marginBottom="5dp"
android:paddingBottom="5dp"
/>
<TextView
android:id="@+id/newsInformation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:textColor="@color/black"
android:textColorLink="@color/com_facebook_blue"
android:paddingLeft="@dimen/feed_item_status_pad_left_right"
android:paddingRight="@dimen/feed_item_status_pad_left_right"
android:paddingTop="@dimen/feed_item_status_pad_top" >
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/viewMore" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_gravity="right"
android:layout_height="wrap_content">
</LinearLayout>
SimpleDraweeView is used here ...
<com.facebook.drawee.view.SimpleDraweeView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:visibility="visible"
android:adjustViewBounds="true"
android:id="@+id/newsImage"/>
The rest of the xml is just for reference just in case it would help
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/pad_5dp">
<TextView
android:id="@+id/awesomeness"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/timestamp"
android:text="Awesomeness: "
android:textSize="@dimen/feed_item_timestamp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/awesomenessCountNumber"
android:text="0"
android:textColor="@color/timestamp"
android:textSize="@dimen/feed_item_timestamp"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/pad_5dp"
android:layout_marginLeft="@dimen/pad_5dp"
android:layout_marginRight="@dimen/pad_5dp">
<Button
android:layout_width="30dp"
android:layout_height="30dp"
android:id="@+id/awesomeButton"
android:layout_marginRight="8dp"
android:background="@drawable/awesome_button_2"/>
<Button
android:layout_width="30dp"
android:layout_height="30dp"
android:id="@+id/facebookSharePost"
android:layout_marginRight="8dp"
android:background="@drawable/facebook_icon"
/>
<Button
android:layout_width="30dp"
android:layout_height="30dp"
android:id="@+id/whatsApp"
android:background="@drawable/whats_app_icon"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
/>
<TextView
android:layout_marginRight="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Report"/>
<Button
android:layout_marginRight="6dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:id="@+id/report"
android:background="@drawable/report_empty" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Guesses as to what you are doing wrong:
wrap_content.
Fresco does not support this unless you also supply a fresco:viewAspectRatio.
See the guide to Drawees and the longer explanation about wrap_content.android:scaleType
. This has no effect on SimpleDraweeViews. You need to use fresco:actualImageScaleType
. Also be sure that fitXY
is really what you want; this does not preserve the aspect ratio. See the documentation on scale types.