title: Responsive width and height when programatically adding views
body: <p>I'm currently using a Table Layout and programatically adding rows and buttons. However, when I add the views a lot of them go off-screen. Is there a way to programatically set the size to the portion of the screen. </p>
  
  <p>I have decent experience with Android, but new to Kotlin.</p>
  
  <p>Here is where I add the views</p>
  
  <pre><code>private fun setupTable () {
      for(i in 0 until this.rowSize) {
          val row = TableRow(context)
          row.layoutParams
          row.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
              ViewGroup.LayoutParams.WRAP_CONTENT)
          for(j in 0 until this.columnSize) {
              val button = Button(context)
              button.apply {
                  layoutParams = TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                      TableRow.LayoutParams.WRAP_CONTENT)
                  text = "R $i C $j"
              }
              row.addView(button)
          }
          wordLayout?.addView(row)
      }
  }
  </code></pre>
  
  <p>Here is the picture for reference. Here I want a 10x10 table and to fit all the buttons inside the TableLayout.</p>
  
  <p><a href="https://i.stack.imgur.com/0vcCs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0vcCs.png" alt="enter image description here"></a></p>