标题几乎说明了一切。 我有一个带有FrameLayout的Activity,我在运行时添加了一个片段。片段中的数据显示正常,但我无法滚动。
活动的布局是:
<RelativeLayout android:id="@+id/content_layout"
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"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.CoordinatorLayout
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout android:id="@+id/fl_content" android:layout_below="@id/toolbar"
android:layout_width="match_parent" android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent" android:layout_height="match_parent"/>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
并且片段的布局是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView android:id="@+id/iv_cover"
android:layout_width="100dp" android:layout_height="100dp" />
<TextView android:id="@+id/tv_release_artistname"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:id="@+id/tv_release_albumname"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:id="@+id/tv_release_year"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:id="@+id/tv_release_label"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:id="@+id/tv_release_style"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:id="@+id/tv_release_notes"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
答案 0 :(得分:0)
您应该将NestedScrollView
作为FrameLayout
的父级,然后在Fragment
上添加FrameLayout
。
现在,当您在FrameLayout
上添加NestedScrollView
时,您将覆盖Fragment
,behaviour
的内容。
切换后也不要忘记在NestedScrollView
上添加$ kill `pidof python`
。