I am using Picasso library to load images and its working fine but after using this library image is not fit to the layout. If I set image directly to the ImageView
then image will be fit to the layout .Is there any option to pass method in Picasso to fit image to layout
Picasso.with(getContext())
.load(R.drawable.dddd).
.into(lavdateimageView);
Even I tried to call following method but no use
fit()
,croptinside()
etc
XML file
<?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="match_parent"
android:background="#ffffff"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:background="#ffffff"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ffffff"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="260dp"
android:layout_marginBottom="3dp"
android:id="@+id/lavdate_image"
android:orientation="vertical"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lavdateimageView" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New Text to"
android:padding="3dp"
android:background="#ffffff"
android:textColor="#000000"
android:layout_margin="3dp"
android:textStyle="bold"
android:id="@+id/sss" />
</LinearLayout>
</ScrollView>
</LinearLayout>
There are two things to know about fit() . First, calling fit() can delay the image request since Picasso will need to wait until the size of the ImageView can be measured. Second, you only can use fit() with an ImageView as the target (we'll look at other targets later).
<ImageView
android:id="@+id/image"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:adjustViewBounds="true"/>
myPicassoProvider.get(activity).load(getImageUrl()).into(image);
In this way your image will be as width as you want and will keep aspect ratio
I had also same problem so I tried this it works fine
Picasso.get()
.load(IMAGE_URL)
.fit()
.centerCrop()
.into(imageView);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With