简体   繁体   中英

Aligning text in Textview for Android (using Html.fromhtml())

I'm trying to display this table of information.

It currently looks like

[这个]

I want it to look like

[这个]

Is there anyway to get this kind of alignment?

Right now, all of this text is in one TextView, and is styled by Html.fromhtml()

So, conceivably, if there is an html solution to this problem, I could apply it to this textview.

The conventional response would be to compose an XML layout and set the fields individually. You could also just keep your HTML as-is and use a WebView instead of a TextView.

You can use html table to achieve this. ex:

<table>
<tr><td>Session Id</td><td>1</td></tr>
<tr><td>Start time</td><td>xyz</td></tr>
</table>

String styledText = "sessionaID:1"; textView.setText(Html.fromHtml(styledText))

I think ur doing same way. If you need solution in HTML form only then simply append the space tag in front of 1. and similarly to next fields also. Means all the possible tag of HTML to get the same look. solution)

better way is just design a XML and U can set gravity and other parameter for text view

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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