简体   繁体   中英

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?

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM