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
211
votes
23 answers

Single TextView with multiple colored text

As the title says, I want to know is it possible to achieve two different colored characters in a single textview element.
Andro Selva
  • 53,910
  • 52
  • 193
  • 240
211
votes
15 answers

Font size of TextView in Android application changes on changing font size from native settings

I want to specify my own text size in my application, but I am having a problem doing this. When I change the font size in the device settings, the font size of my application TextView also changes.
Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
209
votes
11 answers

How do I add a bullet symbol in TextView?

I have a TextView and I want to add a bullet symbol in my text through XML. Is it possible?
Pria
  • 2,743
  • 4
  • 27
  • 30
208
votes
8 answers

Set TextView text from html-formatted string resource in XML

I have some fixed strings inside my strings.xml, something like: Title
Content
and in my layout I've got a TextView which I'd like to fill with the…
slup
  • 5,484
  • 4
  • 19
  • 14
207
votes
6 answers

TextView bold via XML file?

Is there a way to bold the text in a TextView via XML? ?? Thanks
user291701
  • 38,411
  • 72
  • 187
  • 285
206
votes
14 answers

Android TextView : "Do not concatenate text displayed with setText"

I am setting text using setText() by following way. prodNameView.setText("" + name); prodOriginalPriceView.setText("" + String.format(getString(R.string.string_product_rate_with_ruppe_sign), "" + new BigDecimal(price).setScale(2,…
Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
204
votes
4 answers

Change the Right Margin of a View Programmatically?

Can this attribute be changed dynamically in Java code? android:layout_marginRight I have a TextView, that has to change its position some pixels to the left dynamically. How to do it programmatically?
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
202
votes
8 answers

Android Paint: .measureText() vs .getTextBounds()

I'm measuring text using Paint.getTextBounds(), since I'm interested in getting both the height and width of the text to be rendered. However, the actual text rendered is always a bit wider than the .width() of the Rect information filled by…
salezica
  • 74,081
  • 25
  • 105
  • 166
194
votes
4 answers

Android ClickableSpan not calling onClick

I am creating a ClickableSpan, and it is displaying properly with the proper text underlined. However, the clicks are not registering. Do you know what I am doing wrong??? Thanks, Victor Here is the code snippet: view.setText("This is a…
Victor Grazi
  • 15,563
  • 14
  • 61
  • 94
194
votes
11 answers

How to programmatically set maxLength in Android TextView?

I would like to programmatically set maxLength property of TextView as I don't want to hard code it in the layout. I can't see any set method related to maxLength. Can anyone guide me how to achieve this?
UMAR-MOBITSOLUTIONS
  • 77,236
  • 95
  • 209
  • 278
191
votes
16 answers

How do I create a multiline TextField in SwiftUI?

I've been trying to create a multiline TextField in SwiftUI, but I can't figure out how. This is the code I currently have: struct EditorTextView : View { @Binding var text: String var body: some View { TextField($text) …
gabriellanata
  • 3,946
  • 2
  • 21
  • 27
186
votes
25 answers

How to add a line break in an Android TextView?

I am trying to add a line break in the TextView. I tried suggested \n but that does nothing. Here is how I set my texts. TextView txtSubTitle =…
dropsOfJupiter
  • 6,763
  • 12
  • 47
  • 59
186
votes
23 answers

How to adjust text font size to fit textview

Is there any way in android to adjust the textsize in a textview to fit the space it occupies? E.g. I'm using a TableLayout and adding several TextViews to each row. Since I don't want the TextViews to wrap the text I rather see that it lowers the…
rudas
  • 1,861
  • 3
  • 12
  • 4
181
votes
11 answers

How To Set Text In An EditText

How can I set the text of an EditText?
user555910
  • 2,627
  • 6
  • 22
  • 28
180
votes
16 answers

android TextView: setting the background color dynamically doesn't work

Setting the background color programatically of an android TextView doesn't seem to work. I'm I missing something! TextView et = new TextView(activity); et.setText("350"); et.setBackgroundColor(R.color.white); I also have this file (colors.xml) in…
Tawani
  • 11,067
  • 20
  • 82
  • 106