Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

layout format listview

MarkGrahamMarkGraham USMember ✭✭
edited June 2017 in Xamarin.Android

I have a listview with the following layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingLeft="5dp"
    android:paddingBottom="2dp"
    android:paddingTop="2dp"
    android:weightSum="100">
    <TextView
        android:text="City"
        android:layout_width="match_parent"
        android:layout_weight="25"
        android:layout_height="wrap_content"
        android:id="@+id/textCity" />
    <TextView
        android:text="Name"
        android:layout_width="match_parent"
        android:layout_weight="25"
        android:layout_height="wrap_content"
        android:id="@+id/textName" />
    <TextView
        android:text="Wins"
        android:layout_width="match_parent"
        android:layout_weight="25"
        android:layout_height="wrap_content"
        android:id="@+id/textWins" />
    <TextView
        android:text="Loses"
        android:layout_width="match_parent"
        android:layout_weight="25"
        android:layout_height="wrap_content"
        android:id="@+id/textLoses" />
</LinearLayout>

The layout_weight is 25 for each cell.

        android:layout_weight="25"

I want to space out the two left most columns for more width, so I am changing their weight to 30 and the other two weights (two right most) to 20.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingLeft="5dp"
    android:paddingBottom="2dp"
    android:paddingTop="2dp"
    android:weightSum="100">
    <TextView
        android:text="City"
        android:layout_width="match_parent"
        android:layout_weight="30"
        android:layout_height="wrap_content"
        android:id="@+id/textCity" />
    <TextView
        android:text="Name"
        android:layout_width="match_parent"
        android:layout_weight="30"
        android:layout_height="wrap_content"
        android:id="@+id/textName" />
    <TextView
        android:text="Wins"
        android:layout_width="match_parent"
        android:layout_weight="20"
        android:layout_height="wrap_content"
        android:id="@+id/textWins" />
    <TextView
        android:text="Loses"
        android:layout_width="match_parent"
        android:layout_weight="20"
        android:layout_height="wrap_content"
        android:id="@+id/textLoses" />
</LinearLayout>

But the display is not what I want.

What am I doing wrong? It must be something basic.

Best Answer

Answers

  • MarkGrahamMarkGraham USMember ✭✭

    That's it!
    Thanks for the help.

Sign In or Register to comment.