I have a TextView in my application and a user can set any text in this TextView using HTML from the application settings. The user must be able to set the position of the parts of the text in this TextView using HTML tags. But TextView doesn't support 'table' tag or CSS. And I don't know how else to set the position. Is there some tag to set the position? Or maybe it is possible with HTML.TagHandler? If it is possible - how?
Two examples:
I want to set align="center" for one line in this TextView with HTML.
I want to separate text to two or three columns.
How can I do that?
I think what you are describing is a WYSIWYG editor like TinyMCE or CKEditor. These would allow you to align text or use tables to separate text into multiple columns.
to set align, line must have its id or class, without it maybe you can use jquery to find needed line ant align text in it.
Maybe text is splited into paragraphs, than you can find needed paragraph with jquery.
To split text to columns is not so easy, try this: How to divide text into columns, if I get text dynamically for database using Javascript and CSS?
You can try <div align="center">Your line here</div>.
Check out this article to see all the supported HTML tags
Related
Let’s say I have a function that receives a string that represents a text in HTML format and I want to show this text in Flutter. Some words in the text are supposed to be bold. If I have a few bold words in a row, the spaces between the tags are ignored. How can I show the text without it ignoring spaces?
For example if I use this code and wrap the text with the Html widget:
Html(data: "<b>hello</b> <b>world</b>"),
It shows helloworld but I want it to show hello world .
(If I don’t wrap it in Html the spaces are printed but I do need to render Html to a Flutter widget)
I would really appreciate your help.
Use a non-breaking space entity ( ).I don't know if it will work or not, but you should try this.
Html(data: "<b>hello</b> <b>world</b>"),
I ended up using this line and it worked:
Html(data: text.replaceAll("</b> <b>", "</b> <b>")),
I have a text that is sometimes too high and at times one word.
How to put the text in this TextView so that the first two lines are located around the specified spacing?
Should this be done by 2 TextView?
If yes, how can I figure out how much text is placed on the top two lines?
You can use a Spannable to add customizations to a string inside a TextView.
The styling android blog has an excellent post about it: https://blog.stylingandroid.com/introduction-to-spans/
But looking to your print, it seems that the first row will always have a style and the rest another. With this, using two TextViews and customizing the view directly is a better option for code and performance.
For example, doing centered text and underlined etc... could be possible with a lot of textviews but is there a way not to use that much? Or maybe a way to type html and have the result?
How about use HTML tag?
myTextView.setText(Html.fromHtml("<u>Underlined</u>"));
i need to create an activity with the description on an object.
This description is about 1000 characters, on 16 line.
I wanna ask if there is some way or some rule to follow to insert a string big like this in a textview in android?
I only have to format in in the values/string file or i have to do something else?
And in this description there are some link, how can make them clickable? (when i click i wanna open my browser with the link).
To make links clickable just add this to your view :
android:autoLink="web"
Yes you just need to add that text to resources.
Best wishes.
Put the string in strings.xml, set it to a text view inside a scroll view so that it doesn't get hidden on smaller screens, set autoLink to make the links clickable.
I want to display text such that it would be like:
TITLE 1.1
text about title 1.1
TITLE 1.2
text about title 1.2
TITLE 2.1
text about title 2.1
and so on
it would be a scrolling windows, but another problem is text could be lengthy and could span multiple lines. What do you recommend i should breakup my layout with. The length will be more then the screen height so I need scrollbars. Plus need to keep title bold.
Basically I would be printing this text from a String Array. Is it possible to display it directly from arrays or i can also work with simple strings but need to know how should i breakup my layout. like scrollview -> table layout or what?
Yes it is possible to use String Array. I'd recommed to look at ListActivity and ArrayAdapter. Here is the info to start from.