Android滚动视图里面的cordinator布局不滚动

时间:2016-07-08 18:26:44

标签: android android-scrollview

我的应用程序中有一个scrollview,其中包含以下布局,

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="wrap_content">


    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_refresh_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <ScrollView
            android:id="@+id/wallet_scroll"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fillViewport="true">
    <LinearLayout
        android:id="@+id/scroll_container"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="540dp">

此滚动视图部分未按预期滚动。 这是cordinator布局文件,我在viewpager中有上面的文件,在cordinator布局中。

<android.support.design.widget.CoordinatorLayout android:id="@+id/main_content"
                                                 xmlns:android="http://schemas.android.com/apk/res/android"
                                                 xmlns:app="http://schemas.android.com/apk/res-auto"
                                                 xmlns:tools="http://schemas.android.com/tools"
                                                 xmlns:attrs="http://schemas.android.com/apk/res-auto"
                                                 xmlns:fab="http://schemas.android.com/apk/res-auto"
                                                 android:layout_width="match_parent"
                                                 android:layout_height="match_parent"
                                                 android:orientation="vertical"
                                                 >

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapse_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            android:fitsSystemWindows="true">

            <fragment
                android:id="@+id/map"
                android:name="com.google.android.gms.maps.MapFragment"
                android:layout_width="match_parent"
                android:layout_height="425dp"
                android:layout_marginTop="?attr/actionBarSize"
                app:layout_collapseMode="parallax"/>




        <android.support.v7.widget.Toolbar
                                           android:id="@+id/toolbar"
                                           android:layout_width="match_parent"
                                           android:layout_height="?attr/actionBarSize"
                                           android:background="?attr/colorPrimary"
                                           app:layout_scrollFlags="scroll|exitUntilCollapsed"
                                           app:layout_collapseMode="pin">

            <FrameLayout
                android:id="@+id/titleContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"

                android:gravity="center">

            </FrameLayout>

            <ImageButton
                android:id="@+id/btn_ToolBarRightBtn"
                android:layout_width="32dp"
                android:layout_height="28dp"
                android:tag="0"
                android:background="@null"
                android:scaleType="fitXY"
                android:src="@drawable/icon_shopping"
                android:layout_alignParentRight="true"
                android:layout_gravity="right"
                android:layout_marginRight="10dp"
                />



        </android.support.v7.widget.Toolbar>
        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:background="@color/white"
        android:layout_alignParentTop="true"
        android:id="@+id/category_holder"
        android:layout_gravity="left|top"
        android:layout_marginTop="50dp"
        android:visibility="gone">

        <HorizontalScrollView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@color/white"
            android:scrollbars="none"
            android:id="@+id/horizontalScrollView" >
            <LinearLayout
                android:id="@+id/scrollLayout"
                android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"></LinearLayout>
        </HorizontalScrollView>
    </RelativeLayout>




    <com.utils.NonSwipeableViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_gravity="bottom"
        android:background="@color/offwhite"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay"/>

    <com.github.clans.fab.FloatingActionMenu
        android:id="@+id/material_design_android_floating_action_menu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_marginBottom="18dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        fab:menu_animationDelayPerItem="55"
        fab:menu_backgroundColor="@android:color/transparent"
        fab:menu_buttonSpacing="0dp"
        fab:menu_colorNormal="@color/colorPrimary"
        fab:menu_colorPressed="@color/colorPrimaryDark"
        fab:menu_colorRipple="#99d4d4d4"
        fab:menu_fab_label="Filter"
        fab:menu_fab_size="normal"
        fab:menu_icon="@drawable/fab_add"
        fab:menu_labels_colorNormal="#333"
        fab:menu_labels_colorPressed="#444"
        fab:menu_labels_colorRipple="#66efecec"
        fab:menu_labels_cornerRadius="3dp"
        fab:menu_labels_ellipsize="none"
        fab:menu_labels_hideAnimation="@anim/fab_slide_out_to_right"
        fab:menu_labels_margin="0dp"
        fab:menu_labels_maxLines="-1"
        fab:menu_labels_padding="8dp"
        fab:menu_labels_position="left"
        fab:menu_labels_showAnimation="@anim/fab_slide_in_from_right"
        fab:menu_labels_showShadow="true"
        fab:menu_labels_singleLine="false"
        fab:menu_labels_textColor="#f2f1f1"
        fab:menu_labels_textSize="15sp"
        fab:menu_openDirection="up"
        fab:menu_shadowColor="#66aff198"
        fab:menu_shadowRadius="4dp"
        fab:menu_shadowXOffset="1dp"
        fab:menu_shadowYOffset="4dp"
        fab:menu_showShadow="true"
        android:layout_gravity="right|bottom">

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/material_design_floating_action_menu_item1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/add_round_btn"
            fab:fab_label="Location"
            android:tag="1"
            fab:fab_size="mini" />

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/material_design_floating_action_menu_item2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/around_me"
            fab:fab_label="Category"
            android:tag="2"
            fab:fab_size="mini" />
    </com.github.clans.fab.FloatingActionMenu>
    <FrameLayout android:id="@+id/container_details" android:layout_width="match_parent"
                 android:layout_height="match_parent"
        />

</android.support.design.widget.CoordinatorLayout>

这里出了什么问题?

1 个答案:

答案 0 :(得分:0)

ScrollView更改为NestedScrollView

<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />