有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

显示滚动RecyclerView CoordinatorLayout时的java

我用两张幻灯片实现了一个活动,幻灯片内容是一个带有RecyclerView的片段,它从我的服务器加载数据,并用图像创建一个GridLayout(如在图像库中)

我添加了滚动的行为,所以当你滚动时,你不会看到工具栏

我的问题是,当活动以片段开始时,工具栏是半隐藏的,当我继续向下滚动,工具栏是完全隐藏的,下面的坐标布局是暴露的,所以我得到这个东西:Image visualizing my description

正如你所看到的,浅绿色是坐标布局,红色是ViewPager,我想实现的是,当你滚动更多的时候,你只会看到红色背景,而不会看到绿色背景

我的活动是主要的。xml

<安卓.support.design.widget.AppBarLayout
    安卓:id="@+id/appbar"
    安卓:layout_width="match_parent"
    安卓:layout_height="wrap_content"
    安卓:background="@color/backgroundGray"
    安卓:fitsSystemWindows="true">

    <安卓.support.v7.widget.Toolbar
        安卓:id="@+id/toolbar"
        安卓:layout_width="match_parent"
        安卓:layout_height="56dp"
        安卓:background="@color/appGreen"
        app:layout_scrollFlags="scroll|enterAlways">

        <com.apps.haver.getout.libs.view.CustomTextView
            安卓:id="@+id/actionBarTitleText"
            安卓:layout_width="wrap_content"
            安卓:layout_height="wrap_content"
            安卓:layout_centerVertical="true"
            安卓:layout_marginLeft="10dp"
            安卓:ellipsize="end"
            安卓:maxLines="1"
            安卓:text="Get Out"
            安卓:textColor="@color/white"
            安卓:textSize="50sp"
            app:fontName="Peterbuilt.ttf" />

    </安卓.support.v7.widget.Toolbar>

    <LinearLayout
        安卓:layout_width="match_parent"
        安卓:layout_height="wrap_content"
        安卓:background="#565654"
        安卓:orientation="vertical"
        安卓:scrollbars="none">

        <com.apps.haver.getout.libs.slider.SlidingTabLayout
            安卓:id="@+id/tabs"
            安卓:layout_width="match_parent"
            安卓:layout_height="@dimen/normal_row"
            安卓:background="@color/appGreen"
            安卓:elevation="2dp" />

        <安卓.support.v4.view.ViewPager
            安卓:id="@+id/pager"
            安卓:layout_width="match_parent"
            安卓:layout_height="fill_parent"
            安卓:background="#e90f0f" />
    </LinearLayout>

</安卓.support.design.widget.AppBarLayout>

还有我的碎片。xml

<FrameLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:app="http://schemas.安卓.com/apk/res-auto"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.apps.haver.getout.FriendsFragment">


<com.apps.haver.getout.libs.view.AutofitRecyclerView
    安卓:id="@+id/rvPager"
    安卓:layout_width="match_parent"
    安卓:layout_height="match_parent"
    安卓:clipToPadding="false"
    安卓:columnWidth="102dp"
    安卓:fitsSystemWindows="true"
    安卓:scrollbars="vertical" />


<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
    安卓:id="@+id/pressToRetryPanel"
    安卓:layout_width="match_parent"
    安卓:layout_height="match_parent"
    安卓:gravity="center"
    安卓:visibility="gone">

    <TextView
        安卓:id="@+id/textPressToRetry"
        安卓:layout_width="wrap_content"
        安卓:layout_height="wrap_content"
        安卓:layout_centerHorizontal="true"
        安卓:layout_centerVertical="true"
        安卓:text="@string/press_to_retry"
        安卓:textColor="@color/black"
        安卓:textSize="16sp" />
</RelativeLayout>

<include
    安卓:id="@+id/loadingPanel"
    layout="@layout/loading_template"
    安卓:layout_width="match_parent"
    安卓:layout_height="match_parent" />

当我滚动时,如何使工具栏隐藏,但仍能在整个屏幕上看到RecyclerView内容

谢谢


共 (0) 个答案