Android的ListView控件不扩大整个屏幕? (2) [英] Android ListView doesn't expand the whole screen? (2)

查看:199
本文介绍了Android的ListView控件不扩大整个屏幕? (2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有类似的问题在这里之一:
<一href=\"http://stackoverflow.com/questions/7321607/android-listview-doesnt-expand-the-whole-screen\">Android ListView控件不扩大整个屏幕?

I've problem similar to the one here: Android ListView doesn't expand the whole screen?

的XML是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:id="@+id/ResultLayout">

    <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
        <ListView android:layout_width="fill_parent" android:id="@+id/ListView"
            android:layout_height="fill_parent"></ListView>
    </ScrollView>
    <LinearLayout android:id="@+id/pagingPanel"
        android:gravity="center" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:orientation="horizontal"></LinearLayout>
    <Spinner android:layout_width="fill_parent" android:id="@+id/ManSpinner"
        android:layout_height="fill_parent" />
</LinearLayout>

在这种情况下,我应该有一个滚动型 PagingPanel 的LinearLayout 将消失。

In this case, I should have a ScrollView or the PagingPanel LinearLayout will disappear.

请帮助..

编辑:

期望的布局是有堆叠在彼此的顶部的所有元素。但是,如果元素超出页面的高度,涡旋应添加到的ListView

The desired layout is to have all the elements stacked on top of each other. but if the elements exceed the page height, a scroll should be added to the ListView.

推荐答案

如果你有一个垂直的LinearLayout ,你不能有多个 FILL_PARENT layout_height 你的的LinearLayout 元素。什么布局,你想达到什么目的?所有元素的均匀分屏?

If you have a vertical LinearLayout, You can't have multiple fill_parent for layout_height of your LinearLayout elements. What layout you would like to achieve? Uniformly divide screen for all elements?

另外一个问题是,在滚动型使用的ListView 不是一个好主意,也因为的ListView 本身是滚动的。

Another problem is that using ListView in ScrollView is not a good idea also because ListView itself is scrollable.

您应该写你想要什么的布局来实现你的XML。也普遍是一个很好的做法,写你的XML在多个步骤和布局重复,以沃金的解决方案的布局。

You should write what layout you would like to achieve with your XML. Also generally is a good practice to write your XML in multiple steps and iterate to woking solution layout by layout.

编辑:确定,尝试这样的事情:

Ok, try something like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:id="@+id/ResultLayout">

    <ListView android:id="@+id/ListView"
        android:layout_width="fill_parent" 
        android:layout_height="0dp"
        android:layout_weight="1" />

    <LinearLayout android:id="@+id/pagingPanel"
        android:gravity="center" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:orientation="horizontal">

    </LinearLayout>

    <Spinner android:id="@+id/ManSpinner"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" />

</LinearLayout>

这篇关于Android的ListView控件不扩大整个屏幕? (2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆