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
261
votes
25 answers

Android: TextView: Remove spacing and padding on top and bottom

When I have a TextView with a \n in the text,, on the right I have two singleLine TextViews, one below the other with no spacing in between. I have set the following for all three TextViews. android:lineSpacingMultiplier="1"…
700 Software
  • 85,281
  • 83
  • 234
  • 341
255
votes
10 answers

What does ellipsize mean in android?

I've added an EditText to my layout, and added a hint, and made it centered horizontally. When running the application, the hint was invisible. I found that I should make ellipsize value of the TextView to be start:
Hamzeh Soboh
  • 7,572
  • 5
  • 43
  • 54
253
votes
7 answers

How set the android:gravity to TextView from Java side in Android

I can use android:gravity="bottom|center_horizontal" in xml on a textview to get my desired results, but I need to do this programmatically. My textview is inside a tablerow if that matters in a relativelayout. I have tried: LayoutParams…
Nate
  • 2,720
  • 2
  • 16
  • 17
249
votes
21 answers

Right align text in android TextView

I have a TextView in my application. I want to align the text in it to the right. I tried adding: android:gravity="right" But this doesn't work for me. What might I be doing wrong?
Bishan
  • 15,211
  • 52
  • 164
  • 258
244
votes
20 answers

Set color of TextView span in Android

Is it possible to set the color of just span of text in a TextView? I would like to do something similar to the Twitter app, in which a part of the text is blue. See image below: (source: twimg.com)
hpique
  • 119,096
  • 131
  • 338
  • 476
237
votes
12 answers

How to assign text size in sp value using java code

If I assign an integer value to change a certain text size of a TextView using java code, the value is interpreted as pixel (px). Now does anyone know how to assign it in sp?
capecrawler
  • 67,353
  • 7
  • 31
  • 34
235
votes
16 answers

Auto-fit TextView for Android

Background Many times we need to auto-fit the font of the TextView to the boundaries given to it. The problem Sadly, even though there are many threads and posts (and suggested solutions) talking about this problem (example here, here and here),…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
234
votes
31 answers

The specified child already has a parent. You must call removeView() on the child's parent first (Android)

I have to switch between two layouts frequently. The error is happening in the layout posted below. When my layout is called the first time, there doesn't occur any error and everything's fine. When I then call a different layout (a blank one) and…
blackst0ne
  • 3,134
  • 4
  • 16
  • 28
233
votes
10 answers

Remove an onclick listener

I have an object where the text cycles and displays status messages. When the messages change, I want the click event of the object to change to take you to the activity that the message is relating to. So, I have a TextView mTitleView and I'm…
Josh
  • 16,286
  • 25
  • 113
  • 158
229
votes
12 answers

Rounded corner for textview in android

I have a textview and want its corner to be in round shape. I already know it can be done using android:background="@drawable/somefile". In my case, this tag is already included so cannot use again. e.g android:background="@drawable/mydialogbox" is…
Sanjeev Yadav
  • 2,921
  • 7
  • 24
  • 23
223
votes
4 answers

Shadow Effect for a Text in Android?

Possible Duplicate: Android - shadow on text? How can i make shadow effect text in a TextView. Any Idea?
Praveen
  • 90,477
  • 74
  • 177
  • 219
223
votes
12 answers

Set the layout weight of a TextView programmatically

I'm trying to dynamically create TableRow objects and add them to a TableLayout. The TableRow objects has 2 items, a TextView and a CheckBox. The TextView items need to have their layout weight set to 1 to push the CheckBox items to the far right. I…
eugene
  • 2,519
  • 3
  • 17
  • 5
218
votes
4 answers

How do I use a compound drawable instead of a LinearLayout that contains an ImageView and a TextView

Ran the new Lint tool against my code. It came up with a lot of good suggestions, but this one I cannot understand. This tag and its children can be replaced by one and a compound drawable Issue: Checks whether the current node can be replaced by…
216
votes
8 answers

How to click or tap on a TextView text

I know this is so easy (doh...) but I am looking for a way to run a method on tapping or clicking a TextView line of text in an Android App. I keep thinking about button listeners and anonymous method listener calls, but it just does not seem to…
Droid
  • 2,467
  • 2
  • 17
  • 9
215
votes
9 answers

Android selector & text color

I want a simple TextView to behave the way simple_list_item_1 in a ListView does. Here's the XML:
yanchenko
  • 56,576
  • 33
  • 147
  • 165