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

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

概述我有HomeActivity包含片段,在底部它有自定义导航视图,如下所示.通过单击profilepic,它将使用UserProfileView片段替换该片段.userProfileView片段在coordinatorLayout中有Collapsing工具栏.userprofileview.xml<?xmlversion="1.0"encoding="utf-8"?><layoutxmlns:androi

我有HomeActivity包含片段,在底部它有自定义导航视图,如下所示.

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

userprofilevIEw.xml

<?xml version="1.0" enCoding="utf-8"?><layout xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:app="http://schemas.androID.com/apk/res-auto"    xmlns:bind="http://schemas.androID.com/apk/res-auto"    xmlns:tools="http://schemas.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>

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

在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会在屏幕外滚动所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1117414.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存