wasabeef / picasso-transformations

An Android transformation library providing a variety of image transformations for Picasso

Repository from Github https://github.comwasabeef/picasso-transformationsRepository from Github https://github.comwasabeef/picasso-transformations

RoundedCornersTransformation(int radius, int margin, CornerType cornerType) with picasso fit causing image overlapping

hiteshsahu opened this issue · comments

Using Picasso fitfunction along with RoundedCornersTransformation(int radius, int margin, CornerType cornerType) constructor result into overlapping images

Layout xml


   <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:gravity="center_horizontal" >

            <ImageView
                android:id="@+id/with_corner_type"
                android:layout_width="200dp"
                android:layout_height="200dp"
                android:layout_gravity="center_horizontal"
                android:background="#F00"
                android:gravity="center_horizontal"
                android:text="@string/hello_world" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/with_corner_type"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="5dp"
                android:text="With CornerType"
                android:textColor="#FFF" />
        </RelativeLayout>

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:gravity="center_horizontal" >

            <ImageView
                android:id="@+id/without_corner_type"
                android:layout_width="200dp"
                android:layout_height="200dp"
                android:layout_gravity="center_horizontal"
                android:background="#F00"
                android:gravity="center_horizontal"
                android:text="@string/hello_world" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/without_corner_type"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="5dp"
                android:text="Without CornerType"
                android:textColor="#FFF" />
        </RelativeLayout>

Loading images with RoundedCornersTransformation

//Using fit without CornerType
Picasso.with(getApplicationContext()).load(R.drawable.kitten).fit().centerCrop()
                .transform(new RoundedCornersTransformation(50, 50))
                .into((ImageView) findViewById(R.id.without_corner_type));

//Using fit with CornerType
Picasso.with(getApplicationContext()).load(R.drawable.kitten).fit().centerCrop()
                .transform(new RoundedCornersTransformation(50, 50, CornerType.DIAGONAL_FROM_TOP_RIGHT))
                .into((ImageView) findViewById(R.id.with_corner_type));

Result :- The red color highlights actual size of imageView

fitwithcornertype