title: RecyclerView items don't fill width
body: <p>I have designed a layout with map fragment and recyclerView. 
  Each recyclerView item is cardview (I have specified give the xml layout).</p>
  
  <p>The problem is RecyclerView item doesn't fill screen width. 
  <a href="http://i.stack.imgur.com/fz0px.png" rel="noreferrer">img here</a></p>
  
  <p>I tried to change layout_width to <code>fill_parent</code>, <code>match_parent</code> ... but it can't help</p>
  
  <p>Here is the layout <strong>for each item</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
  &lt;android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_margin="8dp"
      android:id="@+id/cardView"&gt;
  
      &lt;LinearLayout
          android:id="@+id/locationItemView"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal"&gt;
  
          &lt;ImageView
              android:layout_width="120px"
              android:layout_height="120px"
              android:id="@+id/imgIcon"
              android:background="@drawable/image_bg"
              android:layout_margin="5dp"
              android:scaleType="fitCenter"
              android:adjustViewBounds="true" /&gt;
  
          &lt;LinearLayout
              android:id="@+id/layoutInfo"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical"&gt;
  
              &lt;TextView
                  android:id="@+id/txtName"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:text="Location Name"
                  android:textColor="#d5c645"
                  android:textStyle="bold"
                  android:textSize="20dp"
                  android:padding="3dp" /&gt;
  
              &lt;TextView
                  android:id="@+id/txtAddress"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:text="Location Address"
                  android:textSize="16dp"
                  android:padding="3dp" /&gt;
  
              &lt;TextView
                  android:id="@+id/txtDistance"
                  android:layout_width="match_parent"
                  android:layout_height="fill_parent"
                  android:text="Location Distance"
                  android:textSize="14dp"
                  android:textStyle="italic"
                  android:padding="2dp"
                  android:textAlignment="viewEnd" /&gt;
          &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p></p>
  
  <p>and the <strong>main_layout</strong></p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout
  android:id="@+id/drawer_layout"
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
  
      &lt;fragment xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          xmlns:map="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
          android:layout_height="0px" android:id="@+id/map" tools:context=".Main"
          android:name="com.google.android.gms.maps.SupportMapFragment"
          android:layout_weight=".6"/&gt;
  
      &lt;android.support.v7.widget.RecyclerView
          android:id="@+id/locationList"
          android:layout_width="match_parent"
          android:layout_height="0px"
          android:layout_weight=".4"
          android:divider="#FEFFCC"
          android:dividerHeight="1dp" /&gt;
  
  &lt;/LinearLayout&gt;
  
  &lt;ListView
      android:id="@+id/navdrawer"
      android:layout_width="250px"
      android:layout_height="match_parent"
      android:layout_gravity="start"
      android:background="?attr/colorPrimaryDark"
      android:choiceMode="singleChoice"
      android:divider="@android:color/white"
      android:dividerHeight="1dp"
      android:drawSelectorOnTop="false"/&gt;
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>Hope anyone can help me. I am stuck with it for 3 days.
  Thank you.</p>
  
  <p>====================================
  Edit on 19/11/15
  I don't thing the problem is my itemView layout because when I change it to GridLayout it still doesn't fill the width.
  Here is my CustomAdapter for RecyclerView</p>
  
  <pre><code>public class LocationDetailsAdapter extends RecyclerView.Adapter&lt;LocationDetailsViewHolder&gt; {
      Context _context;
      ArrayList&lt;LocationDetails&gt; _data;
  
      public LocationDetailsAdapter(Context _context, ArrayList&lt;LocationDetails&gt; _object) {
          this._context = _context;
          _data = _object;
      }
  
      @Override
      public LocationDetailsViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
          View _v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.list_location,null );
          LocationDetailsViewHolder _viewHolder = new LocationDetailsViewHolder(_v);
  
          return _viewHolder;
      }
  
      @Override
      public void onBindViewHolder(LocationDetailsViewHolder locationDetailsViewHolder, int i) {
          LocationDetails _location = _data.get(i);
          locationDetailsViewHolder._imgType.setImageResource(R.drawable.repair_img);
          locationDetailsViewHolder._locationName.setText(_location.get_locationName());
          locationDetailsViewHolder._locationAddress.setText(_location.get_locationAddress() + ", " + _location.get_district() + ", " + _location.get_province());
          locationDetailsViewHolder._distance.setText(String.valueOf(_location.get_distance()) + " km");
  
          locationDetailsViewHolder._locationName.setOnClickListener(clickListener);
          locationDetailsViewHolder._imgType.setOnClickListener(clickListener);
          locationDetailsViewHolder._locationAddress.setOnClickListener(clickListener);
  
  locationDetailsViewHolder._locationName.setTag(locationDetailsViewHolder);
          locationDetailsViewHolder._imgType.setTag(locationDetailsViewHolder);
          locationDetailsViewHolder._locationAddress.setTag(locationDetailsViewHolder);
  }
  
      @Override
      public int getItemCount() {
          return (null != _data ? _data.size() : 0);
      }
  
      View.OnClickListener clickListener = new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              LocationDetailsViewHolder _holder = (LocationDetailsViewHolder)v.getTag();
              int _pos = _holder.getPosition();
  
              int _id = _data.get(_pos).get_id();
  
              Intent _intent = new Intent(CommonFields._context, ItemView.class);
              _intent.putExtra("LocationID",_id);
              _intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              CommonFields._context.startActivity(_intent);
          }
      };
  }
  </code></pre>
  
  <p>and here I get RecylerView in main</p>
  
  <pre><code>_locationView = (RecyclerView)findViewById(R.id.locationList);
  _locationView.setLayoutManager(new LinearLayoutManager(this));
  _adapter = new LocationDetailsAdapter(Main.this, CommonFields._locationData);
  _locationView.setAdapter(_adapter);
  </code></pre>