Dynamic font size
<p>how do I calculate the font size of a TextView so that always occupy a certain percentage of the screen?
now I spit it out:</p>

<pre><code>    .....
densityNormal = Float.parseFloat("1.0");
densitySub = Float.parseFloat("0.75");
densityIper = Float.parseFloat("1.5");
densityExtra = Float.parseFloat("2.0");
.....
textviewSample.setTextSize(getHeightPercentage(context,30));
.....
private float getHeightPercentage(Context context, int percentage) {
    if (percentage &gt; 0 &amp;&amp; percentage &lt; 100) {

        float appHeight = context.getApplicationContext().getResources()
                .getDisplayMetrics().heightPixels;

        float appSPDensity = context.getApplicationContext().getResources()
                .getDisplayMetrics().scaledDensity;

        if (Float.compare(appSPDensity, densitySub) == 0) {
            appHeight = appHeight + ((appHeight * 25) / 100);
        } else if (Float.compare(appSPDensity, densityIper) == 0) {
            appHeight = ((appHeight * 50) / 100) - appHeight;
        } else if (Float.compare(appSPDensity, densityExtra) == 0) {
            appHeight = ((appHeight * 200) / 100) - appHeight;
        }

        return new Float((appHeight * percentage) / 100);
    } else
        return -1;
}
</code></pre>

<p>but I can not integrate the different density of the screen,have you any suggestions?8y3</p>
