Reputation: 746
I have a serious problem with the Picasso library scaling. The problem is that I have a layout consisting of 3 Main views and some buttons. Views are like :
ImageView 50% mapView 20% EditTextView 30%
And I want to load pictures of unknown resolution into that imageView without leaving white spaces. I was trying to use .fit().centerInside but that just left white spaces on the sides. This is how my layout looks like:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_below="@+id/photo1"
android:weightSum="10">
<ImageView
android:id="@+id/photo1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:background="#75aea7ab" />
<com.google.android.gms.maps.MapView
android:id="@+id/map2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2" />
<EditText
android:id="@+id/edittext"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginBottom="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:layout_weight="3"
android:background="#00000000"
android:gravity="top|left"
android:inputType="textMultiLine"
android:textColor="#ff000000"
android:textSize="15sp" />
</LinearLayout>
<ImageButton
android:id="@+id/post"
android:layout_width="@dimen/fab_button_diameter"
android:layout_height="@dimen/fab_button_diameter"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="end"
android:layout_marginBottom="300dp"
android:background="@drawable/fab_shape"
android:src="@drawable/forward"
android:text="Post!"
android:tint="@android:color/white" />
<Button
android:id="@+id/camera"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="75dp"
android:layout_marginTop="100dp"
android:background="@drawable/camera" />
<Button
android:id="@+id/gallery"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="75dp"
android:layout_marginTop="100dp"
android:background="@drawable/gallery" />
Upvotes: 5
Views: 3186
Reputation: 838
Have you try to set the ScaleType after the image has been loaded?
mPicasso.load("yourUrl")
.into(yourImageView, new Callback() {
@Override
public void onSuccess() {
yourImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);//Or ScaleType.FIT_CENTER
}
@Override
public void onError() {
//nothing for now
}
});
Upvotes: 6