简体   繁体   English

如何通过HTML在TextView中设置文本位置?

[英]How to set text position in TextView via HTML?

I have a TextView in my application and a user can set any text in this TextView using HTML from the application settings. 我的应用程序中有一个TextView,用户可以使用应用程序设置中的HTML在此TextView中设置任何文本。 The user must be able to set the position of the parts of the text in this TextView using HTML tags. 用户必须能够使用HTML标记在此TextView中设置文本各部分的位置。 But TextView doesn't support 'table' tag or CSS. 但是TextView不支持'table'标签或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? 或者也许可以使用HTML.TagHandler? If it is possible - how? 如果可能-如何?

Two examples: 两个例子:

  1. I want to set align="center" for one line in this TextView with HTML. 我想用HTML在此TextView中为一行设置align =“ center”。

  2. 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 . 我认为您所描述的是所见即所得的编辑器,例如TinyMCECKEditor 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. 要设置对齐方式,行必须具有其ID或类,否则,您可以使用jquery在其中查找所需的行蚂蚁对齐文本。

Maybe text is splited into paragraphs, than you can find needed paragraph with jquery. 也许文本被拆分为段落,然后您可以使用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? 将文本拆分为列不是那么容易,请尝试以下操作: 如果我使用Javascript和CSS动态获取数据库的文本,如何将文本拆分为列?

You can try <div align="center">Your line here</div> . 您可以尝试<div align="center">Your line here</div>

Check out this article to see all the supported HTML tags 查看本文以查看所有受支持的HTML标记

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM