AlikElzin-kilaka
AlikElzin-kilaka

Reputation: 36041

Android text style missing light, medium, thin,

When setting custom fonts for a textview, I can only choose normal, bold or italic: enter image description here

How can I set the style to be light instead of bold in the following example?

<TextViewWithCustomFont
...
android:textStyle="bold"/>

Upvotes: 34

Views: 54433

Answers (3)

Gibolt
Gibolt

Reputation: 47267

Letter Spacing

As an adjacent solution to change a font's looks, you could use letterSpacing. This will change the distance between the letters within a TextView.

A positive number like 0.2 will add more of a gap, while negative like -0.1 will squish the letters together.

In Android 21+ you can programmatically call setLetterSpacing or in XML add letterSpacing.

Upvotes: -1

Alex Fu
Alex Fu

Reputation: 5527

This is font specific. Not all fonts have a light, medium, thin attribute/style, but the default font should. You can use the default light font by using fontFamily: sans-serif-light or for thin, fontFamily: sans-serif-thin.

For custom fonts, you would need to include the light version of the font and use it.

Upvotes: 72

R&#233;mi F
R&#233;mi F

Reputation: 1335

You can only combine those three attributes :

  • normal
  • bold
  • italic

http://developer.android.com/reference/android/widget/TextView.html#attr_android:textStyle

So it can be :

  • normal
  • bold
  • italic
  • bold | italic

Upvotes: -3

Related Questions