1

我试图在我的一种布局中使用机器人细字体,但是当我将字体系列设置为“sans-serif-thin”时,字体默认为斜体,我无法强制它正常。

<TextView
    android:id="@+id/textLabel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/firstLabel"
    android:fontFamily="sans-serif-thin"
    android:text="for this week"
    android:textSize="30sp"
    android:textStyle="normal"
    android:layout_marginTop="-15dp" />

谁能告诉我在布局中使用机器人超薄普通样式字体的正确方法?

4

2 回答 2

1

我在我的 4.2.2 和 2.2 设备上测试了你的代码,都显示正常字体,没有斜体。也许您在代码中的某处动态设置了不同的文本样式。

于 2013-06-26T15:51:38.360 回答
0

您应该在资产文件夹上创建文件夹字体并将您的字体 XX.ttf 放在那里。然后,使用它:

TextView txt = (TextView) findViewById(R.id.title);  
Typeface font = Typeface.createFromAsset(getAssets(), "XX.ttf");  
txt.setTypeface(font);  
于 2013-06-26T16:00:11.800 回答