mardi 31 mars 2015

Picasso: Get image width and size after fit() method



In my listview, each item has an ImageView laid on a 9-patch shadow background:


there are redundant padding


The problem is the image cannot fit the background because I used Picasso with fit() and centerCrop() from this (code below).



Picasso.with(getActivity())
.load(imageUrl)
.placeholder(R.drawable.placeholder)
.error(R.drawable.error)
.fit().centerCrop()
.into(imageView);


layout view:



<ImageView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/feed_image_shadow"
android:contentDescription="@string/app_name"
android:minHeight="180dp" />


As far as I know, fit() with calculate ImageView's dimension but showdow by 9 patch change the actual image area a little bit. Now I think I have to find image view's dimension after fit() method then change width smaller alittle bit. Do you know how to achieve that or is there any other solution?

Thank you so much


Aucun commentaire:

Enregistrer un commentaire