【问题标题】:ScrollView embedded in TableLayout embedded in RelativeLayout with ListView outside Not Working嵌入在 TableLayout 中的 ScrollView 嵌入在 RelativeLayout 中,外部 ListView 不起作用
【发布时间】:2011-03-22 17:51:45
【问题描述】:

在我添加我的 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!有什么想法吗?

【问题讨论】:

    标签: android listview scrollview tablelayout


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-19
      • 1970-01-01
      • 1970-01-01
      • 2011-12-10
      • 2012-10-24
      • 2015-09-06
      • 2014-02-17
      相关资源
      最近更新 更多