title: Card Presenter expands in Android 4.4 when selected
body: <p>This is the code for <code>cardpresenter.java</code> here the <code>card_width</code> and <code>card_height</code> is specified but it does not follows in Android Kitkat. How to make <code>CardView</code> compatibility with Android 4.4.3?</p>
  
  <pre><code>package com.example.sahilbhatoa.iitv;
  
  import android.graphics.drawable.Drawable;
  import android.support.v17.leanback.widget.ImageCardView;
  import android.support.v17.leanback.widget.Presenter;
  import android.util.Log;
  import android.view.ViewGroup;
  
  import com.bumptech.glide.Glide;
  
  /*
   * A CardPresenter is used to generate Views and bind Objects to them on demand.
   * It contains an Image CardView
   */
  public class CardPresenter extends Presenter {
      private static final String TAG = "CardPresenter";
  
      private static final int CARD_WIDTH = 313;
      private static final int CARD_HEIGHT = 176;
      private static int sSelectedBackgroundColor;
      private static int sDefaultBackgroundColor;
      private Drawable mDefaultCardImage;
  
      private static void updateCardBackgroundColor(ImageCardView view, boolean selected) {
          int color = selected ? sSelectedBackgroundColor : sDefaultBackgroundColor;
          // Both background colors should be set because the view's background is temporarily visible
          // during animations.
  
          view.setBackgroundColor(color);
          view.findViewById(R.id.info_field).setBackgroundColor(color);
      }
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent) {
          Log.d(TAG, "onCreateViewHolder");
  
          sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
          sSelectedBackgroundColor = parent.getResources().getColor(R.color.selected_background);
          mDefaultCardImage = parent.getResources().getDrawable(R.drawable.movie);
  
          ImageCardView cardView = new ImageCardView(parent.getContext())
  
          {
              @Override
              public void setSelected(boolean selected) {
                  updateCardBackgroundColor(this, selected);
                  super.setSelected(selected);
              }
          };
  
          cardView.setFocusable(true);
          cardView.setFocusableInTouchMode(true);
          updateCardBackgroundColor(cardView, false);
          return new ViewHolder(cardView);
      }
  
      @Override
      public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
  
          ImageCardView cardView = (ImageCardView) viewHolder.view;
          cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);
          if (item instanceof Movie)
          {
              Movie movie = (Movie) item;
              Log.d(TAG, "onBindViewHolder");
              if (movie.getCardImageUrl() != null) {
                  cardView.setTitleText(movie.getTitle());
                  cardView.setContentText(movie.getCategory());
                  cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);
                  Glide.with(viewHolder.view.getContext())
                          .load(movie.getCardImageUrl())
                          .centerCrop()
                          .error(mDefaultCardImage)
                          .into(cardView.getMainImageView());
              }
          }
          else
          {
              cardView.setTitleText(item.toString());
              cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);
  
              if (item.toString().equalsIgnoreCase("categories"))
                  Glide.with(viewHolder.view.getContext())
                      .load(R.drawable.categories)
                      .centerCrop()
                      .error(mDefaultCardImage)
                      .into(cardView.getMainImageView());
              else if (item.toString().equalsIgnoreCase("Account Summary"))
                  Glide.with(viewHolder.view.getContext())
                          .load(R.drawable.account_summary)
                          .centerCrop()
                          .error(mDefaultCardImage)
                          .into(cardView.getMainImageView());
              else if (item.toString().equalsIgnoreCase("Video On Demand"))
                  Glide.with(viewHolder.view.getContext())
                          .load(R.drawable.videoondemand)
                          .centerCrop()
                          .error(mDefaultCardImage)
                          .into(cardView.getMainImageView());
              else if (item.toString().equalsIgnoreCase("Customer Support"))
                  Glide.with(viewHolder.view.getContext())
                          .load(R.drawable.customer_support)
                          .centerCrop()
                          .error(mDefaultCardImage)
                          .into(cardView.getMainImageView());
              else if (item.toString().equalsIgnoreCase("Favorites"))
                  Glide.with(viewHolder.view.getContext())
                          .load(R.drawable.favourites)
                          .centerCrop()
                          .error(mDefaultCardImage)
                          .into(cardView.getMainImageView());
  
          }
  
  
      }
  
      @Override
      public void onUnbindViewHolder(Presenter.ViewHolder viewHolder) {
          Log.d(TAG, "onUnbindViewHolder");
          ImageCardView cardView = (ImageCardView) viewHolder.view;
          // Remove references to images so that the garbage collector can free up memory
          cardView.setBadgeImage(null);
          cardView.setMainImage(null);
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/OU3Uh.png" rel="nofollow noreferrer">In this the Card view works perfectly with same code just OS is android 5.0.1</a></p>
  
  <p><a href="https://i.stack.imgur.com/pCezu.png" rel="nofollow noreferrer">Card View expands to full screen. Here the OS is Android 4.4.3</a></p>