[Android] Better fit for images in cardviews

Geoffrey Métais git at videolan.org
Fri Dec 19 19:26:27 CET 2014


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Dec 19 19:25:17 2014 +0100| [35392357713aab2713124784a091d86cb93eca34] | committer: Geoffrey Métais

Better fit for images in cardviews

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=35392357713aab2713124784a091d86cb93eca34
---

 vlc-android/tv/src/org/videolan/vlc/gui/tv/CardPresenter.java |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/CardPresenter.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/CardPresenter.java
index e19a489..458fc83 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/CardPresenter.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/CardPresenter.java
@@ -33,6 +33,7 @@ import android.support.v17.leanback.widget.ImageCardView;
 import android.support.v17.leanback.widget.Presenter;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.ImageView;
 
 public class CardPresenter extends Presenter {
 
@@ -89,14 +90,14 @@ public class CardPresenter extends Presenter {
         cardView.setFocusable(true);
         cardView.setFocusableInTouchMode(true);
         cardView.setBackgroundColor(mRes.getColor(R.color.lb_details_overview_bg_color));
+        cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);
+        cardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER_CROP);
         return new ViewHolder(cardView);
     }
 
     @Override
     public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
         ViewHolder holder = ((ViewHolder) viewHolder);
-        holder.mCardView.getMainImageView().setAdjustViewBounds(true);
-        holder.mCardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);
         if (item instanceof Media) {
             Media media = (Media) item;
             holder.mCardView.setTitleText(media.getTitle());



More information about the Android mailing list