The layout of my activity is like this:
There is a view pager:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/inner_frame_layout_padding"
>
<VerticalViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
The column layout for each entry in viewpager is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:text="Default category"
android:id="@+id/name"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal"
android:id="@+id/recyclerview"/>
</LinearLayout>
And each item of the recyclerview has the layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="10dp"
card_view:cardMaxElevation="10dp"
card_view:contentPadding="10dp">
<RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<ImageView
android:id="@+id/video_thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:tint="@android:color/black"
android:padding="5dp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
In onBindViewHolder I am using this code:
Uri img_uri = Uri.parse(img_url);
final String TAG = "loadImgUrl";
Log.d(TAG, "Loading image from url: " + img_url);
try {
Picasso.with(context)
.setLoggingEnabled(true);
Picasso.with(context)
.load(img_uri)
.resize(250,250)
.centerCrop()
.error(R.drawable.call)
.placeholder(R.drawable.event)
.into(imageView);
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
}
But the result is always a black image. The same code works If I use a drawable stored in the app.
There is no error in picasso log or the app log. I have tried using into(Target) as well but same problem occurs and the error callbacks are never called.
Anyone has any idea why this is so?
you are adding a black to the tint to the image view in which you are showing images.
<ImageView
android:id="@+id/video_thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:tint="@android:color/black"
android:padding="5dp" />
just remove the tint android:tint="@android:color/black"
<ImageView
android:id="@+id/video_thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="5dp" />
read more about tint here and when to use