MotionLayout中断了(嵌套)子视图的重绘 [英] MotionLayout breaks the redrawing of (nested) subviews
问题描述
我在 MotionLayout
中无法刷新视图时遇到问题。
I'm having problems with views not refreshing in MotionLayout
.
似乎在某些时候刷新了 MotionLayout
的/ redraw机制被破坏,子视图(包括嵌套视图)在屏幕上更新自身时出现随机问题。我到目前为止所经历的:
Seems like at some point the refresh/redraw mechanism of MotionLayout
becomes broken and the subviews (including the nested ones) are having random problems updating themselves on the screen. What I have experienced so far:
-
RecyclerView
有时没有刷新。当有新数据可用时,就会发生这种情况,我正在使用 Paging 库来填充数据。我通过在到达新数据时滚动1个像素的解决方法进行了修复-recyclerView.smoothScrollBy(0,1)
。之后,RecyclerView
开始重绘自身。 - 打开键盘后,它会随机混乱嵌套的子视图重绘。 github 此处中存在一个问题,一个人在复制所有这些内容通过将
EditText
添加到正式的MotionLayout
示例中。我看到的一些问题示例:
- 我正在使用
TextInputLayout
和app:endIconMode = clear_text
在MotionLayout->中; ConstraintLayout->当我开始键入内容时(也在关闭键盘后),有时有时不会显示TextInputLayout
和X
按钮。 -
TextView
被部分重绘!我在TextView <中显示
无结果 或
无帖子
文本/ code>,根据某种逻辑在它们之间进行切换,但是在UI中仅显示否
而不刷新整个文本。我已经调试了它,Layout Inspector说一切都很好,文本视图的值为无结果
,但是在屏幕上看不到它。 - 其他一些动画已损坏,例如嵌套的
SwipeRefreshLayout
- 我正在使用
RecyclerView
is not refreshed sometimes. This happens when new data is available, I'm using Paging library to fill the data. I have fixed it with a workaround of scrolling 1 pixel when I got new data there -recyclerView.smoothScrollBy(0,1)
. After that theRecyclerView
starts redrawing itself just fine.- When the keyboard is opened it randomly messes the nested subview redrawing. There is an issue in github here where a guy reproduces all this by adding an
EditText
to officialMotionLayout
examples. Some examples of the problems that I'm seeing:- I'm using
TextInputLayout
withapp:endIconMode="clear_text"
inMotionLayout -> ConstraintLayout -> TextInputLayout
and theX
button is sometimes not shown when I start typing (also after closing the keyboard). TextView
is redrawn partially! I'm showing"No Results"
or"No Posts"
text in aTextView
, switching between them based on some logic, but instead of refreshing the whole text only"No"
is shown in the UI. I have debugged it, Layout Inspector says everything is fine, the text view value is"No Results"
, but I don't see it on the screen.- Some other animations are broken, like indeterminate progress animation of nested
SwipeRefreshLayout
- I'm using
重要提示:在执行过渡时,所有刷新/重绘问题均已修复!当我进入3个嵌套子视图被冻结/部分绘制的混乱状态时,我只需要按下一个触发我的过渡的按钮,它们全部都快乐地重绘自己!
IMPORTANT: All the refresh/redraw issues are fixed when I do a transition! When I come to some messed state where 3 nested subviews are frozen/partially drawn, then I just need to press a button that triggers my transition, and all of them are happily redrawing themselves!
如果这是已知问题,以及是否有解决方法,请告诉我。我可以做1个像素的不可见过渡,但是我什至无法检测 MotionLayout
刷新何时中断,处理键盘和 RecyclerView $的新数据。 c $ c>似乎无法涵盖所有情况。否则,我将不得不回到
ConstraintLayout
并考虑自己实现惊人的 OnSwipe
功能(即使可能在 ConstraintLayout
)中。
Please let me know if this is a known problem and if there is a workaround for this. I could do invisible 1 pixel transition maybe, but I cannot even detect when the MotionLayout
refreshing becomes broken, handling keyboard and new data of RecyclerView
doesn't seem to cover all the cases. Otherwise, I will have to move back to ConstraintLayout
and think on implementing the amazing OnSwipe
functionality myself (if that is even possible in ConstraintLayout
).
推荐答案
不是一个真正的答案,但也是渴望发表评论:
Not really an answer, but too long for a comment:
由于您面临的问题可能有多个根本原因,我建议创建一个Sandbox项目并一次安全地重现每个问题和简单的环境。
Since you are facing multiple problem with possibly multiple root causes, I would suggest to create a Sandbox project and reproduce each problem at a time in a safe and simple environment.
对我来说,您似乎对分页库有一个问题(在这种情况下,不是MotionLayout),而对EditText则存在另一个问题。
To me it seem like you have one problem with the paging lib (not with motionLayout in this case) and another problem with the EditText.
您应检查不带ML的分页代码,并检查EditText问题,而不要滚动视图。我知道这没有多大帮助,但也许可以作为解决这些问题的指南。请记住,MotionLayout仍处于beta中,尤其是2.0.0-beta02和beta03版本因回归错误而非常混乱。更新到最新版本(到目前为止为beta04),或继续使用稳定版本。
You should check your paging code without ML and check your EditText problem without any scrolling views. I know this is not much of a help, but maybe a guide how to tackle these problems. Mind that MotionLayout is still in beta and especially release 2.0.0-beta02 and beta03 was pretty messy with regression errors. Update to the newest version (beta04 as of now) or continue using a stable version.
有时,它还有助于搜索 MotionLayout的官方门票
Sometimes it also helps to search the official tickets for MotionLayout
这篇关于MotionLayout中断了(嵌套)子视图的重绘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!