我在嵌套滚动视图中有相对布局,在相对布局下我有视图分页器选项卡布局和回收者视图。我的问题是嵌套的滚动视图元素没有在滚动视图分页器固定在顶部,而回收者视图在视图分页器下面滚动。我想在布局中也滚动视图分页器。
这是我的下面的代码:
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".Home"
android:orientation="vertical"
android:id="@+id/linearHome"
android:paddingBottom="16dp"
android:layout_marginTop="10dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:layout_marginBottom="50dp">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progress2"
android:layout_centerInParent="true"/>
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:id="@+id/nobook"
android:src="@drawable/nobook"
android:layout_centerInParent="true"
android:visibility="gone"/>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="130dp"
android:id="@+id/homeOffers"/>
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/homeOffers"
android:id="@+id/indicator"
app:tabGravity="center"
app:tabIndicatorHeight="0dp"
app:tabBackground="@drawable/tab_selector"/>
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/indicator"
android:id="@+id/refresh">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recycle"/>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
请让我知道如何获得所需的布局。任何帮助将不胜感激。
谢谢
答案 0 :(得分:0)
您可以更改父级布局并将ScrollView用作子级。
您当前的布局:
{NestedScrollView} (您的父母是谁)->
{RelativeLayout}->
{ProgressBar,
ImageView,
ViewPager等} < / p>
将父级更改为相对布局后:
{RelativeLayout} (现在是您的新父布局。其他所有内容都保持不变)->
{ScrollView} (以前是您的NestedScrollView)- ->
{RelativeLayout}->
{ProgressBar,
ImageView,
ViewPager等}
答案 1 :(得分:0)
尝试一下-SwipeRefreshLayout的app:layout_behavior =“ @ string / appbar_scrolling_view_behavior”属性。