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 に答える