title: In android application RecyclerView view show only half of the phone with
body: <p>Here in my activity_main.xml|
  in my android RecyclerView show only half of the screen, I'm not able to find out the mistake. Help me guys. I was used different layout like relativelayout, constraintlayout, linearlayout. but I was getting only half of the screen RecyclerView with size.</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          tools:context=".MainActivity"&gt;
  
          &lt;android.support.v7.widget.SearchView
              android:id="@+id/search"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:background="@color/colorPrimaryDark"
              android:focusable="false"
              android:visibility="gone"
              app:iconifiedByDefault="false"
              app:queryHint="Search Distributors..." /&gt;
  
          &lt;android.support.v7.widget.RecyclerView
              android:id="@+id/recyclerView"
              android:layout_width="match_parent"
              android:layout_below="@+id/search"
              android:layout_centerInParent="true"
              android:layout_height="match_parent" /&gt;
  
          &lt;Button
              android:id="@+id/btnGet"
              android:visibility="gone"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginTop="10dp"
              android:layout_alignParentBottom="true"
              android:text="get" /&gt;
  
  
      &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Here I attach my MainActivity.java</p>
  
  <pre><code>package com.example.admin.recyclerview;
  
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.DefaultItemAnimator;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.support.v7.widget.SearchView;
  import android.view.View;
  import android.widget.Button;
  
  import com.google.gson.Gson;
  
  import java.util.ArrayList;
  import java.util.List;
  
  
      public class MainActivity extends AppCompatActivity {
  
          private List&lt;Model&gt; models;
          RecyclerView recyclerView;
          private RecyclerView.LayoutManager layoutManager;
          public SearchView searchView;
          private Button button;
          private RecyclerViewAdapter recyclerViewAdapter;
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
              recyclerView = findViewById(R.id.recyclerView);
              recyclerView.setLayoutManager(new LinearLayoutManager(this));
              searchView = findViewById(R.id.search);
              button = findViewById(R.id.btnGet);
              button.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      List&lt;Model&gt; models1 = recyclerViewAdapter.getList();
                      System.out.println("final order list "+new Gson().toJson(models1));
                  }
              });
              searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
                  @Override
                  public boolean onQueryTextSubmit(String query) {
                      return false;
                  }
  
                  @Override
                  public boolean onQueryTextChange(String newText) {
                      if (recyclerViewAdapter != null) {
                          recyclerViewAdapter.getFilter().filter(newText);
                      }
                      return true;
                  }
              });
  
              //recyclerView.setHasFixedSize(true);
  
              models = new ArrayList&lt;&gt;();
              models.add(new Model("rajesh"));
              models.add(new Model("deva"));
              models.add(new Model("merlin"));
              models.add(new Model("antony"));
              models.add(new Model("giri"));
              models.add(new Model("guru"));
              System.out.println("get the position " + 
              models.get(0).getName());
              System.out.println("json view "+new Gson().toJson(models));
              recyclerViewAdapter = new 
              RecyclerViewAdapter(getApplicationContext(), models);
  
              recyclerView.setAdapter(recyclerViewAdapter);
  
          }
      }
  </code></pre>
  
  <p>Here i bellow attach my adapter class</p>
  
  <pre><code>public class RecyclerViewAdapter extends RecyclerView.Adapter&lt;RecyclerViewAdapter.MyViewHolder&gt; implements Filterable {
  
      public Context context;
      private List&lt;Model&gt; modelList;
      private List&lt;Model&gt; myfilterList;
  
  
      public RecyclerViewAdapter(Context context, List&lt;Model&gt; modelList) {
          this.context = context;
          this.modelList = modelList;
          this.myfilterList = modelList;
      }
  
      @NonNull
      @Override
      public MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
          LayoutInflater layoutInflater = LayoutInflater.from(context);
          View view = layoutInflater.inflate(R.layout.recyclerview_items, null);
          return new MyViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int i) {
          Model model = myfilterList.get(i);
          myViewHolder.llMain.setTag(i);
          myViewHolder.textView.setText(model.getName());
      }
  
      @Override
      public int getItemCount() {
          return myfilterList.size();
      }
  
      @Override
      public Filter getFilter() {
          return new Filter() {
              @Override
              protected FilterResults performFiltering(CharSequence constraint) {
                  String text = constraint.toString();
                  if (text.isEmpty()) {
                      myfilterList = modelList;
                  } else {
                      ArrayList&lt;Model&gt; filterable = new ArrayList&lt;&gt;();
                      for (Model model : modelList) {
                          System.out.println("check equal " + model.getName() 
                           + "   " + text);
                          if (model.getName().toLowerCase().contains(text)) {
                              filterable.add(model);
                          }
                      }
                      myfilterList = filterable;
                  }
                  FilterResults filterResults = new FilterResults();
                  filterResults.values = myfilterList;
                  return filterResults;
              }
  
              @Override
              protected void publishResults(CharSequence constraint, FilterResults results) {
                  myfilterList = (ArrayList&lt;Model&gt;) results.values;
                  notifyDataSetChanged();
  
              }
          };
      }
  
      class MyViewHolder extends RecyclerView.ViewHolder {
          TextView textView;
          Button btnAdd, btnMinus;
          LinearLayout llMain;
  
          MyViewHolder(@NonNull View itemView) {
              super(itemView);
              textView = itemView.findViewById(R.id.tvName);
              btnAdd = itemView.findViewById(R.id.btnAdd);
              btnMinus = itemView.findViewById(R.id.btnMinus);
              llMain = itemView.findViewById(R.id.llMain);
  
              btnAdd.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      int pos = (Integer) llMain.getTag();
                      System.out.println("linear layout position details 
                      "+pos);
                      myfilterList.add(pos+1, new Model("dummy"));
                      notifyItemChanged(pos+1);
                      notifyDataSetChanged();
                  }
              });
          }
      }
      public List&lt;Model&gt; getList()
      {
          return myfilterList;
      }
  }
  </code></pre>
  
  <p>Here I bellow attach my item xml</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/llMain"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"&gt;
  &lt;TextView
      android:id="@+id/tvName"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:textAlignment="center"
      android:textSize="16sp"
      android:layout_margin="5dp"/&gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal"&gt;
          &lt;Button
              android:id="@+id/btnAdd"
              android:layout_weight="1"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:text="Add Items"/&gt;
          &lt;Button
              android:id="@+id/btnMinus"
              android:layout_weight="1"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:text="Add Items"/&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>