6

I'm having problems with views not refreshing in MotionLayout.

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:

  1. 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 the RecyclerView starts redrawing itself just fine.
  2. 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 official MotionLayout examples. Some examples of the problems that I'm seeing:
    • I'm using TextInputLayout with app:endIconMode="clear_text" in MotionLayout -> ConstraintLayout -> TextInputLayout and the X 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 a TextView, 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

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!

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).

frangulyan
  • 3,580
  • 4
  • 36
  • 64
  • see my "comment answer". Also you could create 2 seperate SO questions. Right now there are basically 2 questions here which is not good to handle in a single SO post. – muetzenflo Apr 16 '20 at 11:41
  • Maybe I described everything a bit messy, but there is actually 1 problem in my question - MotionLayout doesn't redraw subviews until transition is initiated. I just gave several examples or instances where the problem is reproducible. – frangulyan Apr 16 '20 at 21:40

3 Answers3

0

I am also experiencing issues with update of nested subviews and MotionLayout. Google please fix this issue with MotionLayout.

Using requestLayout() on the nested subviews will often update the Views.

UPDATE motion:visibilityMode="ignore" in Constraint seems to fix the issue

AndreasReiff
  • 188
  • 10
0

By default during transition motionLayout does not honor requestlayout() during transitions.

Add layoutDuringTransition=honorRequest during the transition

<Transition ... motion:layoutDuringTransition="honorRequest" ... \>

hoford
  • 4,918
  • 2
  • 19
  • 19
-1

Not really an answer, but too long for a comment:

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.

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.

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.

Sometimes it also helps to search the official tickets for MotionLayout

muetzenflo
  • 5,653
  • 4
  • 41
  • 82
  • 1
    1. I already found the official tickets describing similar issues by other users and commented there to help developers identify the issue. 2. Changing 1 word in my codes - MotionLayout -> ConstraintLayout fixes all the problems, so it is definitely MotionLayout issue. 3. As I wrote in the question, there is already something better than a sandbox project - official MotionLayout sample code from Google which has the same problems. I also mentioned it to the Google devs in the official tickets. – frangulyan Apr 16 '20 at 21:38