简体   繁体   中英

Alignment of text in a line for TextView

I'm a beginner for Android development. I'm making a simple app which displays a TextView with highlighted text. This is my work.

http://i.stack.imgur.com/U5OPe.png (I cannot upload images directly because I'm new to stackoverflow)

But there is a problem in it. It seems that the text is not aligned vertically in line. I want my TextView to display text like the picture below.

http://i.stack.imgur.com/1sUKd.png

This picture is a part of Quote.fm application for iOS. In this application text is aligned vertically in line.

I have searched answers to this question but I only found answers like

 android:layout_gravity="center"   

or

 android:gravity="center_vertical"

and so on. But these are alignment attributes for content itself, aren't these?

Do anybody know how to achieve Quote.fm-like text display?

UPDATE: I think I told something vague. Let me explain it again.

So, I don't want my text(whole text) to be aligned within a TextView. If you see the last lines of two pictures you can tell the difference. First one's text is attached to the top of its line but second one's text isn't. Sorry for my poor English. But this is my best to explain it. TT

Thanks.

For your TextView, define gravity as:

   android:gravity="center_vertical"

It will work. And "center_vertically" in your question is a typo I think.

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