Search code examples
androidtextviewfont-sizesettext

Change font size in the same textview


Is it possible change size of temperature?

remoteViews.setTextColor(R.id.battery, Color.WHITE);
        remoteViews.setTextViewText(R.id.battery, String.valueOf((int)batteryLevel + "%" + "|" + temperatura + "°C"));

Batterylevel and temperature are in the same textview. I want change size only of temperature. Actually is 50dp. I want 20dp.Hopw can i do it?


Solution

  • You can change the size using HTML code, but I don't think it is possible to specify detailed sizes in dp with it.

    In your case I would use the tag <small> for the temperature:

    remoteViews.setTextColor(R.id.battery, Color.WHITE);
    String styledText = String.valueOf((int)batteryLevel) + "%" + "|" + "<small>" + temperatura + "°C</small>";
    remoteViews.setTextViewText(R.id.battery, Html.fromHtml(styledText));
    

    The list of supported tags is described here: http://www.grokkingandroid.com/android-quick-tip-formatting-text-with-html-fromhtml/