ANDROID:分为2的画面等于零件2列表视图视图、零件、画面、列表

2023-09-12 03:15:50 作者:活得就像个孤独患者,

我试图把2列表视图到我的布局。问题是,我不知道每个列表视图提前大小。第一列表视图可以有几个项目(0,1,2个至约10)和第二列表视图可以有许多项目(100)。

I'm trying to put 2 listviews into my layout. The problem is that I don't know the size of each listview in advance. The first listview could have a few items (0, 1, 2 up to roughly 10) and the second listview could have many items (up to 100).

我试图在1同时设置列表视图的重量,但它没有工作:

I tried to set the weight of both listviews at 1 but it did not work:

=>如果第一个列表视图只有1个项目,第二个99,你看不到的ListView#第一项1 =>它收缩了这么多(相对于列表视图#2),你看不到吧。

=> If the first listview has only 1 item and the second one 99, you don't see the first item of listview #1 => it's shrinks so much (relative to listview #2) that you don't see it.

所以我认为现在可以拆分屏幕,在2等于部分(不管是什么每个列表视图/无论大小),并把两个列表视图中的每一个部分。当然,这需要工作在任何设备上......让我怎么捕捉设备的屏幕大小,将其划分为两强制列表视图大小,使其适合在屏幕各占一半?

So I'm thinking now to split the screen in 2 equals parts (no matter what/no matter the size of each listview) and put the two listviews in each part. Of course it needs to work on any device ... so how do I capture the device screen size, divide it in two and force the listview size to fit in each half of the screen ?

有没有人做到这一点了吗?是否有另一种选项,以显示两个大小不同的列表视图上相同的布局以某种方式(我应该使用滚动型?=>当用户在到达第一个列表视图的结束,第二个列表视图显示=>是,可能吗? )

Has anyone done that already ? Is there another option to show two listviews of different sizes on the same layout (should I use a scrollview in some way ? => when the user is reaching the end of the first listview, the second listview appears => is that possible ??)

感谢您的帮助和任何建议...

Thank you for your help and any suggestion ...

休伯特

推荐答案

我只是不得不封装我的列表视图2成2个独立的linearlayouts =>这两个LinearLayout中有1重量:

I simply had to "encapsulate" my 2 listviews into 2 separate linearlayouts => these 2 linearlayout have a weight of 1 :

    <LinearLayout android:layout_weight="1" 
                    android:layout_height="fill_parent" 
                    android:layout_width="fill_parent">

                <ListView   android:id="@+id/ListView_NASDAQ100" 
                            android:layout_height="fill_parent" 
                            android:layout_width="fill_parent">

                </ListView>
    </LinearLayout>

<LinearLayout android:layout_weight="1" 
                android:layout_height="fill_parent" 
                android:layout_width="fill_parent">

            <ListView   android:id="@+id/ListView_from_52w_HIGHLOW" 
                        android:layout_height="fill_parent" 
                        android:layout_width="fill_parent">

            </ListView>
</LinearLayout>