3

我希望能够使 TextView 粗体。这就是我设置它的外观的方式(我需要在代码中这样做):

nameText.setTextAppearance(getApplicationContext(), R.style.BlueText);
priceText.setTextAppearance(getApplicationContext(), R.style.BlueText);
changeText.setTextAppearance(getApplicationContext(), R.style.BlueText);

这是我的 style.xml

  <!-- Blue Color -->
   <style name="BlueText">
        <item name="android:textColor">#4871A8</item>
    </style>

如何确保我的 TextView 是粗体的?

4

2 回答 2

10
  <!-- Blue Color -->
   <style name="BlueText">
        <item name="android:textColor">#4871A8</item>
        <item name="android:textStyle">bold</item>
    </style>
于 2010-09-28T04:53:54.500 回答
0

在相关说明中,如果您想在没有任何 XML 的情况下执行相同的操作,您可以这样做:

TextView myText = new TextView(this);
myText.setTextColor(Color.BLUE);
myText.setTypeface(Typeface.DEFAULT_BOLD);

于 2013-10-22T23:39:57.680 回答