Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I add a solid line, like show path works in MotionLayout? #224

Open
muhammad-hamza-shahid opened this issue Aug 27, 2021 · 4 comments
Open

Comments

@muhammad-hamza-shahid
Copy link

I want to show a transition line on which my view is moving I have given this tag
app:motionDebug="SHOW_PATH"
but I want to show a solid line instead of line with dashes with keyframes.

@jafu888
Copy link
Contributor

jafu888 commented Aug 27, 2021

That is meant as a debugging feature and should not be used in product.
You can get the paths from the MotionController if you implement a MotionHelper

public class MotionEffect extends MotionHelper {

....
 @Override
    public void onPreSetup(MotionLayout motionLayout, HashMap<View, MotionController> controllerMap) {
    

@muhammad-hamza-shahid
Copy link
Author

@jafu888 Thank's for your response, Can you please elaborate your solution or if possible can you give me any link to specific documentation as I have searched a lot but didn't found anything useful.

@jafu888
Copy link
Contributor

jafu888 commented Aug 27, 2021

This is not documented. You are the first person looking to do something like this.

The idea is you would create subclass motionHelper (say PathDraw) add it to the MotionLayout (Like it was a view) but match parent width and height. Now anything you draw (in code) there would show.

Research Creating a CustomView for tips on drawing.

All the code for MotionEffect, MotionHelper, and MotionLayout can be found here: https://github.com/androidx/constraintlayout

@muhammad-hamza-shahid
Copy link
Author

@jafu888 this is not the ideal solution because it need a lot of calculation of x,y coordinates and it may not work perfectly on different screen sizes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants