0

This question might be so so simple but difficult for me as a beginner. I am developing an Android app by java. So There is a TextView.

How can I add some style to it. Like changing its colour, font and etc ??

Dan Ask
  • 1
  • 3

2 Answers2

0

This will change the color from xml:

<TextView
android:layout_width="wrap_content"
android:layout_height"wrap_content"
android:textColor="#123123"
/>

Changing font is a little bit more in depth. Put your desired font file into the assets folder of your project and use the setTypeface() method of TextView. That has been covered in a previous question: How to change the font on the TextView?

Community
  • 1
  • 1
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
  • Thanks. So are all styles added to its own section? Like isn't there something like CSS that you make a style identified by an id and that applies to all widgets that hold that id ?! – Dan Ask Oct 17 '13 at 00:40
  • you can do something similar, see here: http://developer.android.com/guide/topics/ui/themes.html – FoamyGuy Oct 17 '13 at 00:45
0

Alright, Here is the documentation of TextView. There are basically two ways to style the text view using xml and in java code. Here is the relevent xml attributes:

android:textColor
android:textColorHighlight
android:textColorHint
android:textSize

And so on. On code it would look something like this:

TextView tv = (TextView) findViewById(R.id.tv);
tv.setTextColor(Color.BLACK);
Peshal
  • 1,508
  • 1
  • 12
  • 22