I have a ListView
which has two columns and what I want is to center that ListView
in a Linerlayout
. Here is the layout code of the ListView
.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" >
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/mylist">
</ListView>
</LinearLayout>
And here is the layout of the individual items of the ListView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/prayLabel"
android:layout_width="100dip"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/prayValue"
android:layout_width="100dip"
android:layout_height="wrap_content" />
</LinearLayout>
Although my ListView
is appearing vertically centered, but it's not appearing horizontally centered as its width is spanning the entire width of the screen. I guess as I used wrap_content
in the layout_width
in all the places its width should not span the entire width of the screen/layout?
Thanks