嵌入 TableLayout 中的 ScrollView 嵌入relativelayout 中,listview 外部不工作

发布于 2024-09-12 11:36:49 字数 2668 浏览 3 评论 0原文

在添加 ListView 并将 TableLayout 高度更改为“wrap_content”而不是“fill_parent”之前,我的 ScrollView 显示正确。这是我的 XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent" >
 <TableLayout android:id="@+id/details"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_alignParentBottom="true"
  android:stretchColumns="1">
  <TableRow>
   <TextView android:text="Restaurant Name: " />
   <EditText android:id="@+id/name" />
  </TableRow>
  <TableRow>
   <TextView android:text="Address: " />
   <EditText android:id="@+id/addr" />
  </TableRow>
  <TableRow>
   <TextView android:text="Type:" />
   <ScrollView
    android:layout_height="wrap_content"
    android:layout_width="fill_parent">
   <RadioGroup android:id="@+id/types"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:orientation="vertical">
    <RadioButton android:id="@+id/fastfood"
     android:text="Fast-Food" />
    <RadioButton android:id="@+id/family"
     android:text="Family" />
    <RadioButton android:id="@+id/casual_dining"
     android:text="Casual Dining" />
    <RadioButton android:id="@+id/fine_dining"
     android:text="Fine Dining" />
    <RadioButton android:id="@+id/cafe"
     android:text="Cafe" />
    <RadioButton android:id="@+id/cafeteria"
     android:text="Cafeteria" />
    <RadioButton android:id="@+id/coffeehouse"
     android:text="Coffeehouse" />
    <RadioButton android:id="@+id/pub"
     android:text="Pub" />
    <RadioButton android:id="@+id/greasy_spoon"
     android:text="Greasy Spoon" />
    <RadioButton android:id="@+id/chain"
     android:text="Chain" />
    <RadioButton android:id="@+id/truck_stop"
     android:text="Truck Stop" />
    <RadioButton android:id="@+id/smorgasbord"
     android:text="Smorgasbord" />
   </RadioGroup>
   </ScrollView>
  </TableRow>
  <TableRow>
   <TextView android:text="" />
   <Button android:id="@+id/save"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Save" />
  </TableRow>
 </TableLayout>
 <ListView android:id="@+id/restaurants"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:layout_alignParentTop="true"
  android:layout_above="@id/details" />
</RelativeLayout>

当我有“wrap_content”并且我的显示歪斜时,我没有得到 ScrollView!有什么想法吗?

Before I added my ListView, along with changing my TableLayout height to "wrap_content" as opposed to "fill_parent", my ScrollView displayed properly. Here is my XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent" >
 <TableLayout android:id="@+id/details"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_alignParentBottom="true"
  android:stretchColumns="1">
  <TableRow>
   <TextView android:text="Restaurant Name: " />
   <EditText android:id="@+id/name" />
  </TableRow>
  <TableRow>
   <TextView android:text="Address: " />
   <EditText android:id="@+id/addr" />
  </TableRow>
  <TableRow>
   <TextView android:text="Type:" />
   <ScrollView
    android:layout_height="wrap_content"
    android:layout_width="fill_parent">
   <RadioGroup android:id="@+id/types"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:orientation="vertical">
    <RadioButton android:id="@+id/fastfood"
     android:text="Fast-Food" />
    <RadioButton android:id="@+id/family"
     android:text="Family" />
    <RadioButton android:id="@+id/casual_dining"
     android:text="Casual Dining" />
    <RadioButton android:id="@+id/fine_dining"
     android:text="Fine Dining" />
    <RadioButton android:id="@+id/cafe"
     android:text="Cafe" />
    <RadioButton android:id="@+id/cafeteria"
     android:text="Cafeteria" />
    <RadioButton android:id="@+id/coffeehouse"
     android:text="Coffeehouse" />
    <RadioButton android:id="@+id/pub"
     android:text="Pub" />
    <RadioButton android:id="@+id/greasy_spoon"
     android:text="Greasy Spoon" />
    <RadioButton android:id="@+id/chain"
     android:text="Chain" />
    <RadioButton android:id="@+id/truck_stop"
     android:text="Truck Stop" />
    <RadioButton android:id="@+id/smorgasbord"
     android:text="Smorgasbord" />
   </RadioGroup>
   </ScrollView>
  </TableRow>
  <TableRow>
   <TextView android:text="" />
   <Button android:id="@+id/save"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Save" />
  </TableRow>
 </TableLayout>
 <ListView android:id="@+id/restaurants"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:layout_alignParentTop="true"
  android:layout_above="@id/details" />
</RelativeLayout>

I get no ScrollView when I have "wrap_content" and my display is askew! Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离笑几人歌 2024-09-19 11:36:49

实际上我用不同的高度值做了一些实验。当我提供特定的高度时,总显示就是它应该的样子。我只是向 TableLayout 高度和 ScrollView 高度添加了一个特定值,一切都很好。

我不知道为什么会这样,但它确实有效。如果有人想解释其中的逻辑...请随意! :)

I actually did some experimenting with different values in the height. When I provide a specific height, the total display is how it should be. I simply added a specific value to my TableLayout height and my ScrollView height and all is well.

I am not sure why this is so, but it works. If anyone wishes to explain the logic...feel free! :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文