I\'m finding it impossible to center the text in my listview, tried wrap_content and layout_gravity=center on virtually everything vet the text doesn\'t move
here\'s
android:layout_gravity="center"
indicates to the parent of the textview how it should be placed. This is not what you want here because a ListView ignores that attribute. Replace it with android:gravity="center"
. This tells the TextView how to align the text inside it, in this case center it.
This will have no effect when your textview doesn't fill the whole space though (since the text will match the size of the view, so align doesn't change much). Since you only have a textview in each entry it makes sense to set both android:layout_width
and android:layout_height
to fill_parent
.
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:paddingTop="10dip"
android:paddingBottom="10dip"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#ff000000"
android:background="#ffffffff"
android:gravity="center"
/>
try this android:layout_centerhorizontal="true"
in place of android:layout_gravity="center"
in your text view
application name center alignment in android`