title: How to change button size programmatically in Android?
body: <p>I am creating buttons and adding them to a LinearLayout programmatically. However, I am struggling with changing the button sizes. In the code below, no matter what num I enter in deleteBtn.setWidth(num), and deleteBtn.setHeight(num), nothing changes.</p>
  
  <pre><code>private void populateHorizontalLayouts(CustomMessageEvent event) {
      // Need to remove all views each time an user adds a number
      // so that the same number is not rendered multiple times.
  
      nameAndNumbersLayout.removeAllViews();
  
      //displayedNamesAndNumbers.add(event.getCustomMessage());
      for(int i =0; i &lt; displayedNamesAndNumbers.size(); i++){
          String displayedNumberAndName = displayedNamesAndNumbers.get(i);
  
          LinearLayout horizontalLayout = new LinearLayout(view.getContext());
          horizontalLayout.setOrientation(LinearLayout.HORIZONTAL);
          horizontalLayout.setId(i);
  
          Button deleteBtn = new Button(view.getContext());
          deleteBtn.setId(i);
          deleteBtn.setText("Delete");
          deleteBtn.setWidth(5);
          deleteBtn.setHeight(5);
  
          TextView nameAndNumView = new TextView(view.getContext());
          nameAndNumView.setId(i);
          nameAndNumView.setText(displayedNumberAndName);
  
          horizontalLayout.addView(deleteBtn);
          horizontalLayout.addView(nameAndNumView);
  
          nameAndNumbersLayout.addView(horizontalLayout);
      }
  }
  </code></pre>
  
  <p>What should I write so that the button size changes?</p>