首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >滚动视图滚动列表视图而不是布局

滚动视图滚动列表视图而不是布局
EN

Stack Overflow用户
提问于 2017-06-06 22:24:48
回答 2查看 147关注 0票数 0

我正在开发一个包含两个列表视图的布局。当列表视图扩展超过布局大小时,我想滚动布局,但它滚动列表视图。

如何滚动布局而不是列表视图。

我的代码:

fragment_one.xml

代码语言:javascript
复制
        <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:fillViewport="true" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                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" >
                </ListView>

                <ListView
                    android:id="@+id/list_regional"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dip"
                    android:background="#4A9C67" >
                </ListView>
            </LinearLayout>

        </ScrollView>
EN

回答 2

Stack Overflow用户

发布于 2017-06-06 22:37:02

尝试像这样的NestedScrollView

代码语言:javascript
复制
  <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            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" >
            </ListView>

            <ListView
                android:id="@+id/list_regional"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dip"
                android:background="#4A9C67" >
            </ListView>
        </LinearLayout>

     </android.support.v4.widget.NestedScrollView>
票数 0
EN

Stack Overflow用户

发布于 2017-06-06 22:42:08

尝试此操作,删除使用RelativeLayoutLinearLayout

代码语言:javascript
复制
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true" >

  <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <ListView
        android:id="@+id/list_nation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:background="#B29090" >
         </ListView>

         <ListView
        android:id="@+id/list_regional"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:background="#4A9C67"  >
        </ListView>
  </RelativeLayout>
</ScrollView>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44392686

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档