Issue
I'm sorry if this is a duplicate but i couldn't find anything that was quite what I'm looking for. Basically, i want to align the text in the text View to be in the top center. And I would like to do this in XML if possible. So i want to combine
android:gravity="center"
and
android:gravity="top"
so that it aligns it with both. I have already tried to put both attributes in the text View element but it just gives an error.
Solution
First, you cannot duplicate the attribute, though you can combine values.
android:gravity="g1|g2"
However, center
implies both vertical and horizontal centering so top|center
wouldn't be correct. You should use
android:gravity="top|center_horizontal"
Answered By - matiash
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)