第二个列表视图未在线性布局中扩展fragemnt

时间:2017-06-08 18:58:12

标签: android listview android-linearlayout

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

我在线性布局中使用了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 个答案:

答案 0 :(得分:0)

在单个屏幕中添加多个卷轴时,它始终显示问题。因为他们互相冲突。 您的问题有两种解决方案。

  1. 如果您想让每个列表视图占据半个屏幕,请在主线性布局中添加“weightsum = 100”,并将两个列表视图的权重设置为“50”。
  2. 如果您希望第一个列表滚动到结尾,并且在第一个列表结束时希望第二个列表开始滚动,则在运行时计算列表的高度,并将计算出的高度分配给列表视图。请检查:Android: How to measure total height of ListView