这个代码中的错误是什么,请告诉我这种方法是否正确。
当我加载列表项时,列表正在扩展到搜索栏,而不是整个屏幕。请告诉我。
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#000044">
<TableRow>
<EditText
android:id="@+id/txtUserName"
android:width="270dp" />
<Button
android:id="@+id/Search_button"
android:width="50dp" />
/>
</TableRow>
<TableRow>
<ListView
android:id="@+id/Service_name_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
还告诉我,这适用于所有屏幕。
答案 0 :(得分:0)
更改第二行,如下所示:
<TableRow android:layout_span="2">
<ListView
android:id="@+id/Service_name_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</TableRow>
唯一改变的是android:layout_span =“2”等于HTML colspan。
答案 1 :(得分:0)
添加layout_span以强制一个单元格跨越两个单元格。
<ListView
android:id="@+id/Service_name_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_span="2"/>