Actually, I am trying to build a game in which the scene is outside the screen. I want my screen to scroll towards the right so that my that scene comes to the screen when I click any button. I am doing it using motionLayout in Android studio. Can any one help?
Asked
Active
Viewed 418 times
-1
-
try it with horizontal scrollview – Manoj Mohanty Feb 25 '22 at 15:50
-
yes i tried but didnt find it useful. – Romail Bhatti Feb 25 '22 at 15:53
-
i think i wad doing it wrong..can you please demonstrate? – Romail Bhatti Feb 25 '22 at 15:53
-
1for now post your code snippet how are you doing what is the current state and how you want it to be so that others also can help – Manoj Mohanty Feb 25 '22 at 15:55
1 Answers
1
I motionLayout you would constrain the view fully on screen in one state and fully off screen in the other. Than the transition would "slide" the view in.
The typical problem when people do this with MotionLayout is how to constrain a "full size view" outside the bounds of the screen.
There are several ways to accomplish this 2 are:
- used layout_width="match_parent" & layout_constraintLeft_toRightOf="parent"
- use layout_width="0dp" & layout_constraintLeft_toRightOf="parent" andlayout_constraintWidth_percent="1"
The key is you are constraining the left side of the view to the right side of the parent.
This is an example of layout the constraints for slide in.

hoford
- 4,918
- 2
- 19
- 19