How to make sure that centered texts in the app will always look the same on any android phone

9 views
Skip to first unread message

mugetsu

unread,
Feb 13, 2012, 12:28:04 AM2/13/12
to phonegap
I'm building an android app and I've encountered the text centering
issue.

Right now what I'm doing is the following:
<span style="font-size:17px; margin:20%;color:black;">Centered
title goes here</span>

I was able to obtain the right margin by trial and error, but this is
only from my droid phone. I would imagine that on other phones with
different dimensions, the perfectly centered texts I have will not
necessary look so nice.

What should I be doing instead? Or is what I'm doing good enough?

thanks

Kerri Shotts

unread,
Feb 13, 2012, 1:11:01 AM2/13/12
to phon...@googlegroups.com
Use:

<div style="font-size:17px; text-align: center; color: black">Centered Title</div>

Better yet, do something like this:

In your stylesheet:

div.title { font-size:17px; text-align: center; color: black; }

In your code:

<div class="title">Centered Title</div>
Reply all
Reply to author
Forward
0 new messages