title: custom listview shows large space between them when adding a new item by clicking on button in android studio
body: <p><a href="https://i.stack.imgur.com/msi4w.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/msi4w.jpg" alt="enter image description here" /></a></p>
  <p>I have got a custom listview. I am trying to add items to the custom listview by clicking on the button. When I click the button, I want the items to show one under the other but it shows a big space between items.  Data read from the database are listed in the listview at the same time.it works like chat applications. Thanks for your help</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
  
  
      android:layout_height=&quot;wrap_content&quot;
      tools:context=&quot;.Mainactivity&quot;&gt;
  
  
  
  
      &lt;ListView
          android:id=&quot;@+id/listid&quot;
  
          android:layout_width=&quot;match_parent&quot;
          android:divider=&quot;@drawable/dessen&quot;
          android:layout_above=&quot;@+id/lineerid&quot;
          android:dividerHeight=&quot;3dp&quot;
          android:layout_height=&quot;wrap_content&quot;&gt;
      &lt;/ListView&gt;
  
  
  
  
  
  
      &lt;LinearLayout
          android:id=&quot;@+id/lineerid&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_alignParentLeft=&quot;true&quot;
          android:layout_alignParentBottom=&quot;true&quot;
          android:layout_marginLeft=&quot;0dp&quot;
          android:layout_marginBottom=&quot;3dp&quot;
          android:background=&quot;#91f1f1f1&quot;
          android:orientation=&quot;horizontal&quot;
          android:paddingBottom=&quot;2dp&quot;&gt;
  
  
          &lt;EditText
              android:id=&quot;@+id/mesajid&quot;
              android:layout_width=&quot;252dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_alignTop=&quot;@+id/gonderid&quot;
              android:layout_alignParentLeft=&quot;true&quot;
              android:layout_alignParentBottom=&quot;true&quot;
              android:layout_toLeftOf=&quot;@+id/sendMessageButton&quot;
              android:layout_weight=&quot;0.72&quot;
              android:ems=&quot;10&quot;
              android:maxHeight=&quot;80dp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/gonderid&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:textColor=&quot;#ffffff&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:background=&quot;@drawable/buttonsekil&quot;
              android:layout_alignParentRight=&quot;true&quot;
              android:layout_alignParentBottom=&quot;true&quot;
              android:text=&quot;Gönder&quot; /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p>custom _layout</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:background=&quot;#ffffff&quot;
      android:orientation=&quot;vertical&quot;&gt;
  
      &lt;LinearLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
  
          android:orientation=&quot;horizontal&quot;&gt;
  
          &lt;TextView
              android:id=&quot;@+id/nickid&quot;
              android:layout_width=&quot;120dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_gravity=&quot;left&quot;
              android:textColor=&quot;#352925&quot;
              android:textSize=&quot;18sp&quot;
              android:textStyle=&quot;bold&quot;&gt;
  
  
          &lt;/TextView&gt;
  
  
          &lt;TextView
              android:id=&quot;@+id/tarihid&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:gravity=&quot;right&quot;
              android:textColor=&quot;#352925&quot;
              android:textSize=&quot;18sp&quot;
              android:textStyle=&quot;bold&quot;&gt;
  
  
          &lt;/TextView&gt;
  
  
      &lt;/LinearLayout&gt;
  
  
      &lt;LinearLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_marginTop=&quot;10dp&quot;
          android:layout_height=&quot;wrap_content&quot;&gt;
  
          &lt;TextView
              android:id=&quot;@+id/formesajid&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:textColor=&quot;#050505&quot;
              android:textColorLink=&quot;#9C27B0&quot;
              android:textSize=&quot;16sp&quot;
              android:textStyle=&quot;bold&quot;&gt;
  
  
          &lt;/TextView&gt;
  
      &lt;/LinearLayout&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>custom adapter</p>
  <pre><code>public class customadapter extends BaseAdapter {
  
  
      private LayoutInflater layoutInflater;
  
      private List&lt;Model&gt; modelList;
  public customadapter(Activity activity,List&lt;Model&gt; modelList) {
  
  layoutInflater= (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
  this.modelList=modelList;
  }
  
  
      @Override
      public int getCount() {
          return modelList.size();
      }
  
      @Override
      public Object getItem(int position) {
          return modelList.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
      View view;
      view=layoutInflater.inflate(R.layout.custom_layout,null);
          TextView nick =view.findViewById(R.id.nickid);
          TextView tarih=view.findViewById(R.id.tarihid);
          TextView mesaj=view.findViewById(R.id.formesajid);
          Model model=modelList.get(position);
  
  nick.setText(model.getNickname());
  tarih.setText(model.getTarih());
  mesaj.setText(model.getMesaj());
          return view;
      }
  }
  </code></pre>