其他分享
首页 > 其他分享> > android-片段UI冻结在事务中,但在从片段返回堆栈中还原相同片段时工作流畅

android-片段UI冻结在事务中,但在从片段返回堆栈中还原相同片段时工作流畅

作者:互联网

我有一个活动,一次显示一个片段,总共有三个不同的片段.
包含RecyclerView和ThirdFragment的FirstFragment和SecondFragment具有ScrollView.

问题是当片段在运行时附加时,UI冻结,但是自定义OnItemClickListener侦听器可以正常工作.当我选择FirstFragment的任何列表项时,它将重定向到SecondFragment,这是另一个列表视图. SecondFragment也被冻结.但是,如果我使用“后退”按钮返回,则FirstFragment可以顺利运行.类似地,当我选择SecondFragment列表项时,我将重定向到最后一个位置,即ThirdFragment,这也是一个滚动视图,也将冻结,如果我回到SecondFragment,它将开始顺利运行,但是如果我回到FirstFragment并再次选择任何列表项,再次进入SecondFragment UI冻结.

注意:此问题仅出现在4.2.2 Jelly Bean的OS版本5.0(棒棒糖及更高版本)上,一切正常.在Android OS版本5.0上,支持库的TextInputLayout动画存在相同的冻结问题,但在4.2.2 Jelly Bean上运行良好

我创建了一个Gist的活动,三个相应的片段,RecyclerView.Adapter和自定义OnItemClickListener

ProductActivity.java,ProductCategoryFragment.java,ProductListFragment.java,ProductDetailFragment.java,ItemClickSupport.java

任何帮助,将不胜感激.谢谢

编辑

在活动启动时,我得到以下日志.

04-01 16:28:47.241 32176-32176/com.example.omkar D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
04-01 16:28:47.371 32176-32176/com.example.omkar I/Timeline: Timeline: Activity_launch_request id:com.example.omkar time:77715999
04-01 16:28:47.381 32176-32176/com.example.omkar W/ResourcesManager: getTopLevelResources: com.example.omkar for user  0
04-01 16:28:47.391 32176-32176/com.example.omkar W/ResourcesManager: getTopLevelResources: com.example.omkar for user  0
04-01 16:28:47.401 32176-32176/com.example.omkar D/PhoneWindow: *FMB* installDecor mIsFloating : false
04-01 16:28:47.401 32176-32176/com.example.omkar D/PhoneWindow: *FMB* installDecor flags : -2139029248
04-01 16:28:47.431 32176-32176/com.example.omkar D/Activity: performCreate Call Injection manager
04-01 16:28:47.431 32176-32176/com.example.omkar I/InjectionManager: dispatchOnViewCreated > Target : com.example.omkar.userInterface.activity.product.ProductActivity isFragment :false
04-01 16:28:47.431 32176-32176/com.example.omkar D/DisplayManager: DisplayManager()
04-01 16:28:47.461 32176-32176/com.example.omkar D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
04-01 16:28:47.461 32176-32176/com.example.omkar D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
04-01 16:28:47.491 32176-32176/com.example.omkar W/View: View too large to fit into drawing cache, needs 10563840 bytes, only 3686400 available
04-01 16:28:47.501 32176-32176/com.example.omkar W/View: View too large to fit into drawing cache, needs 10563840 bytes, only 3686400 available
04-01 16:28:47.511 32176-32176/com.example.omkar I/InjectionManager: dispatchCreateOptionsMenu :com.example.omkar.userInterface.activity.product.ProductActivity
04-01 16:28:47.511 32176-32176/com.example.omkar I/InjectionManager: dispatchPrepareOptionsMenu :com.example.omkar.userInterface.activity.product.ProductActivity
04-01 16:28:47.531 32176-32176/com.example.omkar W/View: View too large to fit into drawing cache, needs 10563840 bytes, only 3686400 available
04-01 16:28:47.561 32176-32176/com.example.omkar I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@1d12fb86 time:77716194
04-01 16:28:47.921 32176-32176/com.example.omkar W/View: View too large to fit into drawing cache, needs 10563840 bytes, only 3686400 available
04-01 16:28:47.961 32176-32191/com.example.omkar I/art: Background sticky concurrent mark sweep GC freed 32383(1734KB) AllocSpace objects, 7(112KB) LOS objects, 9% free, 16MB/18MB, paused 5.876ms total 38.048ms

解决方法:

问题已解决.这是因为我在AndroidManifest.xml文件中提到了android:hardwareAccelerated =“ false”.

找到的答案:https://stackoverflow.com/a/21145043/4387543

标签:android-fragments,android-5-0-lollipop,android
来源: https://codeday.me/bug/20191118/2031415.html