【发布时间】:2018-07-09 07:14:51
【问题描述】:
一个包含在 RelativeLayout 中的 WebView(包含 vimeo 或 youtube 视频)以及一些 TextView 将以编程方式添加到 postViewContainer 中。有时,它只是一些 TextViews 和 ImageViews,但大多数时候,它有一个 WebView。
videoFullScreenContainer 用于将视频放大到全屏模式
eplComments 包含一个 cmets 列表。每条评论都有一个回复列表。
这里的问题是 postViewContainer 不是可滚动的一部分。甚至 eplComments 也不能正常工作。向上滚动时,它会在一直向上滚动之前触发 pull to refresh。
如何让 postViewContainer 成为可滚动的一部分,并解决与 SwipeRefreshLayout 的滚动冲突?
postViewContainer 不能是 eplComments 的项目,因为如果是,则每当 eplComments 中的项目更新时,webview 内的视频都会重新加载.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/mainContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:theme="@style/AppTheme.AppBarOverlay">
...
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/swipeRefreshLayout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:id="@+id/postViewContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</FrameLayout>
<ExpandableListView
android:id="@+id/eplComments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerHeight="0dp"
android:childDivider="@null"
android:divider="@null"
android:groupIndicator="@null"
/>
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
<FrameLayout
android:id="@+id/videoFullScreenContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</RelativeLayout>
更新: 我还尝试将 SwipeRefreshLayout 的内容包装在 NestedScrollView 中,如下所示。这里的问题是它只加载 ExpandableListView 中的第一项。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/mainContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:theme="@style/AppTheme.AppBarOverlay">
...
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/swipeRefreshLayout">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:orientation="vertical">
<FrameLayout
android:id="@+id/postViewContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</FrameLayout>
<ExpandableListView
android:id="@+id/eplComments"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="0dp"
android:childDivider="@null"
android:divider="@null"
android:groupIndicator="@null"
/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
<FrameLayout
android:id="@+id/videoFullScreenContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</RelativeLayout>
【问题讨论】:
标签: android listview expandablelistview android-coordinatorlayout swiperefreshlayout