title: Auto fit according to screen size in grid layout android
body: <p>I have created a grid containing full of texts. I want the text to auto-fit according to screen size. I have tried the following code,</p>
  
  <pre><code>    DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
      float dpWidth = displayMetrics.widthPixels / displayMetrics.density;
      int noOfColumns = (int) (dpWidth / 50);
      return noOfColumns;
  </code></pre>
  
  <p>I want output something like this   </p>
  
  <p><a href="https://i.stack.imgur.com/bw2MJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bw2MJ.png" alt="image"></a>]<a href="https://i.stack.imgur.com/XMqhJ.png" rel="noreferrer">2</a></p>
  
  <p><a href="https://i.stack.imgur.com/DIl00.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DIl00.png" alt="imag2"></a>
  It doesn't work as per my need. Please help . Thanks in advance.</p>