android– 如果折叠了backPressed,工具栏就会消失

android– 如果折叠了backPressed,工具栏就会消失,第1张

概述当backPressed时,我的工具栏变得不可见或消失.仅当工具栏折叠时才会出现这种情况.>我在Fragment上有一个RecyclerView>滚动回收器时,工具栏会折叠>如果我进入下一个活动,由一些回收者调用,然后按下后退按钮,工具栏就会消失.>如果我滚动回收器,折叠仍然会发生,但工具栏不在那里,只

当backpressed时,我的工具栏变得不可见或消失.仅当工具栏折叠时才会出现这种情况.

>我在Fragment上有一个RecyclerVIEw
>滚动回收器时,工具栏会折叠
>如果我进入下一个活动,由一些回收者调用,然后按下后退按钮,工具栏就会消失.
>如果我滚动回收器,折叠仍然会发生,但工具栏不在那里,只是一个没有任何内容的垂直空间.

片段布局

<androID.support.design.Widget.CoordinatorLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"xmlns:app="http://schemas.androID.com/apk/res-auto"androID:ID="@+ID/main_content"androID:layout_wIDth="match_parent"androID:layout_height="match_parent"androID:fitsSystemwindows="true">  <androID.support.design.Widget.AppbarLayout    androID:ID="@+ID/appbar"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:minHeight="?attr/actionbarSize"    androID:theme="@style/themeOverlay.AppCompat.Dark.Actionbar"    androID:fitsSystemwindows="true">        <!--Toolbar-->        <androID.support.v7.Widget.Toolbar                        androID:ID="@+ID/toolbar"            app:layout_scrollFlags="scroll|enteralways"            app:popuptheme="@style/themeOverlay.AppCompat.light"            androID:background="@color/theme_primary"            app:layout_collapseMode="none" />    <!--Toolbar Sort-->    <androID.support.v7.Widget.Toolbar                androID:ID="@+ID/toolbar_sort"        androID:title="Toolbar"        app:popuptheme="@style/themeOverlay.AppCompat.light"        androID:background="@color/theme_primary_dark"        androID:visibility="gone"        app:layout_collapseMode="pin" />   </androID.support.design.Widget.AppbarLayout>  <androID.support.v7.Widget.RecyclerVIEw    xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:app="http://schemas.androID.com/apk/res-auto"    androID:ID="@+ID/fragment_taskList_recyclervIEw"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    app:layout_behavior="@string/appbar_scrolling_vIEw_behavior" />  <!--ADD Fragment Container-->  <@R_301_4614@Layout    androID:ID="@+ID/add_container"    androID:layout_wIDth="match_parent"    androID:fitsSystemwindows="true"    androID:layout_height="match_parent" /></androID.support.design.Widget.CoordinatorLayout>

调用Fragment上的布局

@OverrIDepublic VIEw onCreateVIEw(LayoutInflater inflater, VIEwGroup container, Bundle savedInstanceState) {    fragmentVIEw    = inflater.inflate(R.layout.taskList_fragment, container, false);

一些可能的问题

W/VIEw﹕ requestLayout() improperly called by androID.support.v7.Widget.Toolbar{335f934 V.E..... ......ID 0,0-1080,168 #7f0d009c app:ID/toolbar} during layout: running second layout passW/VIEw﹕ requestLayout() improperly called by androID.support.design.Widget.CollapsingToolbarLayout{3c2cf991 V.ED.... ......I. 0,0-1080,420 #7f0d009a app:ID/collapsing_toolbar} during second layout pass: posting in next frame

解决方法:

原来我的代码还可以.
问题是由appcompat lib上的一些错误引起的.我刚刚将支持库更新到版本22.2.1,问题就消失了.

compile "com.androID.support:appcompat-v7:22.2.1"compile "com.androID.support:support-annotations:22.2.1"compile "com.androID.support:design:22.2.1"compile 'com.androID.support:recyclervIEw-v7:22.2.1'compile 'com.androID.support:cardvIEw-v7:22.2.1'
总结

以上是内存溢出为你收集整理的android – 如果折叠了backPressed,工具栏就会消失全部内容,希望文章能够帮你解决android – 如果折叠了backPressed,工具栏就会消失所遇到的程序开发问题。

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

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

原文地址: https://outofmemory.cn/web/1119204.html

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

发表评论

登录后才能评论

评论列表(0条)

保存