第二个列表视图不在线性布局fragnst中扩展



我的线性布局具有两个列表视图,当我在第二个列表视图中添加项目时,它不会扩展。它会自动滚动,

我在线性布局中使用了match_parent,即使第二个列表视图(滚动而不是扩展(或线性布局没有扩展。

任何人都可以帮助我扩展列表视图或线性布局。

线性布局或第二个列表视图中的问题?

但是第一个列表视图正确扩展。

fragment_one.xml

        <LinearLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:layout_weight="1"
                android:descendantFocusability="blocksDescendants"
                android:padding="10dip" >
                <ListView
                    android:id="@+id/list_nation"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dip"
                    android:background="#B29090"
                    android:nestedScrollingEnabled="true">
                </ListView>
                <ListView
                    android:id="@+id/list_regional"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dip"
                    android:background="#4A9C67"
                    android:focusable="false"
                    android:nestedScrollingEnabled="true">
                </ListView>
            </LinearLayout>

在单个屏幕中添加多个卷轴时,总是会显示问题。因为他们彼此冲突。有两个解决方案解决您的问题。

  1. 如果您想将每个listView保留为半屏幕,则在主线性布局中添加" weightsum = 100",并将两个listView的权重设置为" 50"。
  2. 如果您希望第一个列表滚动直至结束,并且在第一个列表结束时,您希望第二个列表开始滚动,然后在运行时间内计算列表的高度,并将计算出的高度分配给您的listViews。检查以下内容:Android:如何测量ListView的总高度

最新更新