【发布时间】:2017-06-29 22:34:32
【问题描述】:
我有一个列表视图,每一行都在放大以下视图后显示。它是一个 LinearLayout,它工作正常,直到我给每个 textview(这是我列表中的一列)相同的大小。如果我改变任何这些宽度,我会得到意想不到的结果。例如,如果我将 0.5 放在第一个 textView(称为“测试”)上,我希望 textView 的大小要小得多,但事实恰恰相反。所以我尝试使用 3,但又是非常意外的行为。因此,如果我希望第一个 textView 比其他 4 个小得多,我该怎么做呢?
<?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" />
【问题讨论】:
标签: android xml android-layout listview xamarin