嵌入 TableLayout 中的 ScrollView 嵌入relativelayout 中,listview 外部不工作
在添加 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上我用不同的高度值做了一些实验。当我提供特定的高度时,总显示就是它应该的样子。我只是向 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! :)