Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在CoordinatorLayout中使用时,android – footer会在屏幕外滚动大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有HomeActivity包含片段,在底部它有自定义导航视图,如下所示.

在CoordinatorLayout中使用时,android – footer会在屏幕外滚动

通过单击profile pic,它将使用UserProfileView片段替换该片段. userProfileView片段在coordinatorLayout中有Collapsing工具栏.

userprofileview.xml

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://scheR_217_11845@as.android.com/apk/res/android"
    xmlns:app="http://scheR_217_11845@as.android.com/apk/res-auto"
    xmlns:bind="http://scheR_217_11845@as.android.com/apk/res-auto"
    xmlns:tools="http://scheR_217_11845@as.android.com/tools">

    <data>

        <variable
            name="resource"
            type="com.example.app.model.resourceData" />


        <import type="android.view.View" />

    </data>

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:BACkground="@color/bg_home"
        android:fitsSystemWindows="true">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/app_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:BACkground="@color/bg_home">

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/toolbar_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">


                </LinearLayout>
            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            app:layouT_Behavior="@String/appbar_scrolling_view_behavior">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_10sdp"
                android:orientation="horizontal">

                <ImageView
                    android:id="@+id/ic_list"
                    android:layout_width="@dimen/_17sdp"
                    android:layout_height="@dimen/_17sdp"
                    android:layout_gravity="center"
                    android:layout_marginLeft="@dimen/_10sdp"
                    android:BACkground="@drawable/ic_list_SELEcted" />

                <ImageView
                    android:id="@+id/ic_grid_view"
                    android:layout_width="@dimen/_15sdp"
                    android:layout_height="@dimen/_15sdp"
                    android:layout_gravity="center"
                    android:layout_marginLeft="@dimen/_10sdp"
                    android:BACkground="@drawable/ic_grid_unSELEcted" />
            </LinearLayout>

            <android.support.v7.widget.RecyclerView
                android:visibility="gone"
                android:id="@+id/rv_post"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:resource="@{resourcE}" />

        </LinearLayout>
    </android.support.design.widget.CoordinatorLayout>
</layout>

问题是,当我点击底部导航菜单中的任何其他菜单时,它会滚动屏幕,如下所示.

在CoordinatorLayout中使用时,android – footer会在屏幕外滚动

在UserProfileView framgment中添加CoordinatorLayout后发生此问题.

如果我用LinearLayout替换CoordinatorLayout然后它工作正常但没有获得折叠工具栏的功能.

谢谢!

解决方法

你的fragment_user_profile.xml中的android:fitsSystemWindows =“true”会导致问题.简单……它使您的抽屉布局看起来全屏.

粗略地说,用户屏幕保持顶部指标边距而主屏幕没有.所以主屏幕作为指标大小向上移动. (实际上不是,有关fitsSystemWindows的详细信息:
Why would I want to fitsSystemWindows)

因此,从fragment_user_profile.xml中删除fitsSystemWindows将解决您的问题.

我建议你将fitsSystemWindows添加到activity_main.xml中的container_body,但我不确定实际代码是什么,所以这是你的调用.

大佬总结

以上是大佬教程为你收集整理的在CoordinatorLayout中使用时,android – footer会在屏幕外滚动全部内容,希望文章能够帮你解决在CoordinatorLayout中使用时,android – footer会在屏幕外滚动所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。