title: How to set text size depending on the screen dimensions?
body: <p>I need to set all the text content of the application depending on the screen dimensions. I mean buttons, textviews etc... For example, If i execute the app ina Pixel C tablet, the buttons text size and the textviews text size must be very big, and very small in a 320x240 device.</p>
  <p>First I tried <code>autoSizeTextType</code> but finally I discart this approach because it can only be applyed to TextView and not to Buttons, etc...</p>
  <p>After that, I tried this approach: <a href="https://developer.android.com/training/multiscreen/screendensities" rel="nofollow noreferrer">https://developer.android.com/training/multiscreen/screendensities</a> creating 4 folders inside res folder:</p>
  <pre><code>values-hdpi
  values-mdpi
  values-xhdpi
  values-xxhdpi
  </code></pre>
  <p>And inside them a <code>dimens.xml</code> file with the text size values, for example, this is the file inside the <code>values-xhdpi</code> folder:</p>
  <pre><code>&lt;resources&gt;
      &lt;dimen name=&quot;big_text&quot;&gt;35sp&lt;/dimen&gt;
      &lt;dimen name=&quot;medium_text&quot;&gt;25sp&lt;/dimen&gt;
      &lt;dimen name=&quot;small_text&quot;&gt;20sp&lt;/dimen&gt;
  &lt;/resources&gt;
  </code></pre>
  <p>And for the other folders i put different values to test it.</p>
  <p>It works... but... is not the behaviour I'm searching for. Why? Because I executed the application in two different xhdpi emulators, the Pixel C and the Nexus 4. Pixel C has bigger resolution, but the screen is super big, so both devices uses the same <code>dimens.xml</code> file, but the buttons and texts are being displayed small in Pixel C and super big in Nexus 4, as you can see in this picture:</p>
  <p><a href="https://i.stack.imgur.com/KrIDc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KrIDc.png" alt="enter image description here" /></a></p>
  <p>What should I do to get text size value which occupies the same portion of the screen for a phrase in all the devices?</p>