0
我有一個列表視圖,每行都在膨脹以下視圖後顯示。它是一個LinearLayout,並且它工作正常,直到我給每個textview(這是列表中的一列)相同的大小。如果我改變任何這些寬度,我會得到意想不到的結果。例如,如果我將0.5放到第一個textView(稱爲「測試」),我期望textView具有更小的尺寸,但它卻相反。所以我嘗試了使用3,但又是非常意外的行爲。所以如果我想讓第一個textView比其他4個小得多,我該怎麼做?Xamarin中列表視圖的不同列大小
<?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="30dp"
android:paddingLeft="5dp"
android:paddingTop="2dp">
<TextView
android:text="Test"
android:layout_width="match_parent"
android:layout_weight="3"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#333333"
android:id="@+id/testView" />
<TextView
android:text="Name"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#333333"
android:id="@+id/nameView" />
<TextView
android:text="Surname"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#333333"
android:id="@+id/surnameView" />
<TextView
android:text="Age"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#333333"
android:id="@+id/ageView" />
<TextView
android:text="Profession"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#333333"
android:id="@+id/professionView" />
非常感謝您的回答。只是有點困惑,所以請多問我道歉。我的目標是使第一個textView(名爲「Test」)比其他4個textView小得多。假設第一個textView的內容只是*或空的,所以最多隻有1個字符。我想要其他4個textViews平等地填充剩餘的空間。我應該爲其他人使用android:layout_height =「wrap_content」,android:layout_weight =「1」嗎? – opt
是的,只需刪除第一個TextView中的android:layout_weight屬性即可。 –
@opt,你解決了這個問題嗎? –