title: Modifying Images resolution and size to fit card view properiries
body: <p>I have an error message from my android app , which using card view and recycle view , i think the problem with the size and resolution for allocated images, this is the error message :</p>
  
  <blockquote>
    <p>D/skia: --- allocation failed for scaled bitmap
        D/AndroidRuntime: Shutting down VM
        W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41775898)
        E/AndroidRuntime: FATAL EXCEPTION: main
                          java.lang.OutOfMemoryError
                              at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
                              at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:586)
                              at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:439)
                              at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832)
                              at android.content.res.Resources.loadDrawable(Resources.java:2988)
                              at android.content.res.Resources.getDrawable(Resources.java:1558)
                              at android.support.v7.widget.ResourcesWrapper.getDrawable(ResourcesWrapper.java:128)
                              at android.support.v7.widget.TintResources.getDrawable(TintResources.java:45)
                              at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:374)
                              at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:202)
                              at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:190)
                              at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
                              at android.support.v7.widget.AppCompatImageHelper.setImageResource(AppCompatImageHelper.java:73)
                              at android.support.v7.widget.AppCompatImageView.setImageResource(AppCompatImageView.java:81)
                              at pioneers.safwat.animals.RecyclerAdapterbirdse.onBindViewHolder(RecyclerAdapterbirdse.java:71)
                              at pioneers.safwat.animals.RecyclerAdapterbirdse.onBindViewHolder(RecyclerAdapterbirdse.java:11)
                              at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6310)
                              at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6343)
                              at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5289)
                              at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5552)
                              at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5394)
                              at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5390)
                              at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2149)
                              at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1533)
                              at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1496)
                              at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:593)
                              at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3537)
                              at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3266)
                              at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3798)
                              at android.view.View.layout(View.java:15213)
                              at android.view.ViewGroup.layout(ViewGroup.java:4793)
                              at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1167)
                              at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:852)
                              at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:871)
                              at android.view.View.layout(View.java:15213)
                              at android.view.ViewGroup.layout(ViewGroup.java:4793)
                              at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
                              at android.view.View.layout(View.java:15213)
                              at android.view.ViewGroup.layout(ViewGroup.java:4793)
                              at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:437)
                              at android.view.View.layout(View.java:15213)
                              at android.view.ViewGroup.layout(ViewGroup.java:4793)
                              at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
                              at android.view.View.layout(View.java:15213)
                              at android.view.ViewGroup.layout(ViewGroup.java:4793)
                              at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
                              at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
                              at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
                              at android.view.View.layout(View.java:15213)
                              at android.view.ViewGroup.layout(ViewGroup.java:4793)
                              at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
                              at android.view.View.layout(View.java:15213)
                              at android.vie
        I/Process: Sending signal. PID: 30359 SIG: 9
        Application terminated.</p>
  </blockquote>
  
  <p>this is my card layout XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:card_view="http://schemas.android.com/apk/res-auto"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:id="@+id/card_view"
      android:layout_margin="5dp"
      card_view:cardBackgroundColor="#81C784"
      card_view:cardCornerRadius="12dp"
      card_view:cardElevation="3dp"
      card_view:contentPadding="4dp"
      android:foreground="?selectableItemBackground"
      android:clickable="true" &gt;
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:padding="16dp" &gt;
  
          &lt;ImageView
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:id="@+id/item_image"
              android:scaleType="fitXY"
              android:adjustViewBounds="true"
              android:layout_alignParentStart="true"
              android:layout_alignParentLeft="true"
              android:layout_alignParentTop="true"
              android:layout_alignParentRight="true"/&gt;
  
          &lt;TextView
              android:layout_marginTop="8dp"
              android:id="@+id/item_title"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="center_vertical"
              android:gravity="center"
              android:textSize="16pt"
              android:paddingLeft="10dp"
              android:layout_below="@+id/item_image"
              /&gt;
  
  
      &lt;/RelativeLayout&gt;
  
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>