Questions tagged [textview]

Text View is an UI element that allows users to view and/or modify the displayed text. Use this tag for programming questions related text views, and add the relevant programming language or technology tag to get more exposure for your question. General UX questions regarding where to place a text view, and other similar opinion based questions are not on topic for Stack Overflow.

14126 questions
466
votes
22 answers

Android TextView Justify Text

How do you get the text of a TextView to be Justified (with text flush on the left- and right- hand sides)? I found a possible solution here, but it does not work (even if you change vertical-center to center_vertical, etc).
user130076
437
votes
25 answers

Is there an easy way to add a border to the top and bottom of an Android View?

I have a TextView and I'd like to add a black border along its top and bottom borders. I tried adding android:drawableTop and android:drawableBottom to the TextView, but that only caused the entire view to become black.
emmby
  • 99,783
  • 65
  • 191
  • 249
386
votes
25 answers

Android, How to limit width of TextView (and add three dots at the end of text)?

I have a TextView that I want to limit characters of it. Actually, I can do this but the thing that I'm looking for is how to add three dots (...) at the end of string. This one shows the text has continue. This is my XML but there is no dots…
Hesam
  • 52,260
  • 74
  • 224
  • 365
367
votes
30 answers

how to make a specific text on TextView BOLD

I don't know how to make a specific text on TextView become BOLD. its like this txtResult.setText(id+" "+name); I want the output to be like this: 1111 neil id and name are variables that I have retrieved the value from database, and I want to…
Budi Darmawan
  • 3,743
  • 3
  • 14
  • 7
354
votes
9 answers

Programmatically set left drawable in a TextView

I have a textView in xml here.
coder_For_Life22
  • 26,645
  • 20
  • 86
  • 118
351
votes
18 answers

android on Text Change Listener

I have a situation, where there are two fields. field1 and field2. All I want to do is empty field2 when field1 is changed and vice versa. So at the end only one field has content on it. field1 = (EditText)findViewById(R.id.field1); field2 =…
inrob
  • 4,969
  • 11
  • 38
  • 51
348
votes
4 answers

How to set text color of a TextView programmatically?

How can I set the text color of a TextView to #bdbdbd programatically?
Noby
  • 6,562
  • 9
  • 40
  • 63
340
votes
8 answers

What is meant by Ems? (Android TextView)

What is meant by Ems (related to a TextView)? For example in android:ems setEms(int) Makes the TextView be exactly this many ems wide.
Addev
  • 31,819
  • 51
  • 183
  • 302
307
votes
13 answers

Android - set TextView TextStyle programmatically?

Is there a way to set the textStyle attribute of a TextView programmatically? There doesn't appear to be a setTextStyle() method. To be clear, I am not talking about View / Widget styles! I am talking about the following:
Jake Wilson
  • 88,616
  • 93
  • 252
  • 370
305
votes
16 answers

How to change the font on the TextView?

How to change the font in a TextView, as default it's shown up as Arial? How to change it to Helvetica?
Praveen
  • 90,477
  • 74
  • 177
  • 219
289
votes
26 answers

How to set the part of the text view is clickable

I have the text "Android is a Software stack". In this text i want to set the "stack" text as clickable. So, if you click on that it will redirected to a new activity(not in the browser). I tried but i am not getting a solution.
naresh
  • 10,332
  • 25
  • 81
  • 124
277
votes
11 answers

Android TextView padding between lines

I have a TextView which displays a long text. I want to give some space between lines like in CSS with line-height property. How can I do it?
Cagatay Gurturk
  • 7,186
  • 3
  • 34
  • 44
272
votes
32 answers

How do I add a newline to a TextView in Android?

When I define a TextView in xml, how do I add a new line to it? \n seems not to work.
Pentium10
  • 204,586
  • 122
  • 423
  • 502
270
votes
8 answers

Is there a way to style a TextView to uppercase all of its letters?

I would like to be able to assign a xml attribute or style to a TextView that will make whatever text it has in ALL CAPITAL LETTERS. The attributes android:inputType="textCapCharacters" and android:capitalize="characters" do nothing and look like…
cottonBallPaws
  • 21,220
  • 37
  • 123
  • 171
263
votes
13 answers

Set style for TextView programmatically

I'm trying to use the TextView constructor with style like this: TextView myText = new TextView(MyActivity.this, null, R.style.my_style); However, when I do this, the text view does not appear to take the style (I verified the style by setting it…
Ben
  • 16,124
  • 22
  • 77
  • 122