这是我的xml的基本模型:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/background_colour"
>
<android.support.design.widget.AppBarLayout
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:id="@+id/profile_screen_appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true"
android:minHeight="150dp"
>
<android.support.design.widget.CollapsingToolbarLayout
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
android:id="@+id/collapsingToolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:expandedTitleMarginTop="32dp"
app:expandedTitleMarginBottom="32dp"
app:expandedTitleMarginEnd="4dp"
app:expandedTitleMarginStart="32dp"
android:minHeight="100dp"
>
<android.support.v7.widget.Toolbar
android:minHeight="100dp"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:background="@color/fab_material_red_500"
>
</android.support.v7.widget.Toolbar>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blue"
>
<!-- the ViewPager is programatically set to be have the height and width equivalent to that of the screen width of the device --> <com.example.heavymagikhq.MyViewPager
android:padding="0dp"
android:fitsSystemWindows="true"
android:id="@+id/viewPager"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_scrollFlags="scroll|enterAlways"/>
/>
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:layout_marginTop="15dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/profile_info_recycler"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
</android.support.design.widget.CoordinatorLayout>
问题
目前,RecyclerView
中的某些内容略微偏离屏幕,我可以通过滚动来显示它。问题在于,尽管只有一点点的内容不在屏幕上,但整个屏幕滚动都向上滚动,直到只有回收库的内容显示在折叠式Toolbarlayout的屏幕顶部,以折叠的高度等于工具栏。我已经尝试将android:layout_gravity="fill_vertical"
添加到RecyClerview,但这并没有解决问题
note
当collapsingtoolbarlayout的高度设置为625dp时,屏幕根本不会滚动,但是当我将其设置为626dp时,屏幕的内容滚动滚动,直到将collapsingtoolbarlayout折叠到工具栏的高度,所以此额外的1dpP高度使屏幕从不滚动到滚动超过1DP。625DP图可能与设备的屏幕尺寸有关。另外,无论我将CollapsingToolBarlayout设置为哪个minHeight
,CollapsingToolBarlayout总是以等于工具栏的高度倒塌。
简而言之我的问题
我该如何制作它,以便屏幕仅滚动以揭示屏幕/超出回收库内容内容的内容?
预先感谢。
我找到了解决方案,您可以为AppBarlayout ChildView设置" minheight",并设置App:layout_scrollflags =" scroll | exituntilcollapsed"