Reputation: 13
I'm trying to make the text all centered but it's not working out. Here's my xml code
<TextView
android:id="@+id/creditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:textColor="#ffffff"
android:layout_marginLeft="0dp"
android:layout_marginTop="350dp"
android:gravity="center"
android:maxLines="6"
android:text="
Dalton Metlzer: Lead Programer/Designer
Cole Selensky: Lead Designer/Programer
Carson Rego: Lead Artist
Carly R: Logo Artist
Evan Swonke: Music Composer/Performer
Blake Jackson: Narator"
/>
instead it just gets all jumbled up.
this is how it looks https://i.sstatic.net/ZDfPy.png
Upvotes: 1
Views: 107
Reputation: 1461
The android:gravity attribute takes effect in the content of the TextView but as you have also android:layout_width="wrap_content" you don't have where to center on.
Either put
android:gravity="center"
android:layout_width="match_parent"
to grow the TextView and center internally, or
android:layout_gravity="center_horizontally"
android:layout_width="wrap_content"
to keep the minimal width of the TextView and center it on it's parent
Upvotes: 0
Reputation: 2097
First of all you need to format your text with new line and all and than some change inxml file like remove
android:layout_marginTop="350dp"
new xml code like this
<TextView
android:id="@+id/creditText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="20dp"
android:textColor="#000000"
android:layout_marginLeft="0dp"
android:gravity="center"
android:maxLines="6"
android:text="
Dalton Metlzer: Lead Programer/Designer
Cole Selensky: Lead Designer/Programer
Carson Rego: Lead Artist
Carly R: Logo Artist
Evan Swonke: Music Composer/Performer
Blake Jackson: Narator"
/>
Here I not format text.
Format text as per your requirement.
Upvotes: 0
Reputation: 879
May be Useful this Code
<TextView
android:id="@+id/creditText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="0dp"
android:layout_marginTop="350dp"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="20dp"
android:maxLines="6"
android:text="Dalton
Metlzer: Lead Programer/Designer\n
Cole Selensky: Lead Designer/Programer\n
Carson Rego: Lead Artist\n
Carly R: Logo Artist\n
Evan Swonke: Music Composer/Performer\n
Blake Jackson: Narator"
/>
Upvotes: 0
Reputation: 1611
just try this :
<TextView
android:id="@+id/creditText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:gravity="center"
android:maxLines="6"
android:text="
Dalton Metlzer: Lead Programer/Designer
Cole Selensky: Lead Designer/Programer
Carson Rego: Lead Artist
Carly R: Logo Artist
Evan Swonke: Music Composer/Performer
Blake Jackson: Narator"
android:textColor="#ffffff"
android:textSize="20dp" />
Upvotes: 0
Reputation: 20563
You have given spaces between those names. I assume you want a vertical list of names centered within the page. In this case, Instead of spaces, at the end of every name, hit enter so you get a newline character. Then you can get a nice centered vertical list of names.
Upvotes: 1