title: ListVIew's item layout height depending on the amount of items
body: <p>I have ListView of items and I want to set the height of each item depending on the amount of items in order the listview to fullfill the screen. </p>
  
  <p>First i get the window size without bar:</p>
  
  <pre><code>//returns height of the app window in pixels
  public static int windowHeight(Context context){
  
          int barH = 0; //bar height
          int height = 125;//DpToPx(context, 125); //default
          int displayH;
  
      try {
          //getting stastus bar height
          int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
          if (resourceId &gt; 0) {
              barH = context.getResources().getDimensionPixelSize(resourceId);
          }
  
          //getting all the screen height
  
          WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
          Display display = wm.getDefaultDisplay();
          Point size = new Point();
          if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB_MR2) {
              display.getSize(size);
              displayH = size.y;
  
          } else {
              //noinspection deprecation
              displayH = display.getHeight();
          }
  
          height = displayH - barH;
      }
      catch (Exception e){
          e.printStackTrace();
      }
          return height;
      }
  </code></pre>
  
  <p>Then in MenuAdapter I am trying to set height:</p>
  
  <pre><code>//set up the height of listrow depending on the amount of menu items in order the listview to fullfill the screen
  private void setupRowHeight(LinearLayout l) {
      LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)l.getLayoutParams();
      int margin = lp.topMargin + lp.bottomMargin;
      int itemsAmount = content.size();
      lp.height = Util.windowHeight(context) / itemsAmount - margin*itemsAmount;
      Log.i("height of row", String.valueOf(l.getLayoutParams().height) + " " + String.valueOf(margin));
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And LinearLayout in RowLayout.xml is:</p>
  
  <pre><code>&lt;LinearLayout
      android:orientation="horizontal"
      android:layout_gravity="center_vertical"
      android:id="@+id/elem"
      android:layout_width="fill_parent"
      android:layout_height="@dimen/row_height"
      android:background="@drawable/layout_bord"
      android:layout_marginLeft="@dimen/row_margin_horiz"
      android:layout_marginRight="@dimen/row_margin_horiz"
      android:layout_marginTop="@dimen/row_margin_vert"
      android:layout_marginBottom="@dimen/row_margin_vert"&gt;
      .....................................................
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>But the items appeear not exactly having a bit more or less height. 
  I just don't get what I didn't take into account?</p>