As stated in Constraint Layout guides:
If a view has no constraints when you run your layout on a device, it is drawn at position [0,0] (the top-left corner).
You must add at least one horizontal and one vertical constraint for the view.
I guess you haven't applied any constraints.
Either manually apply constraints to the view, or let the layout editor do it for you using "Infer constraints" button:
When you drop a view into the Layout Editor, it stays where you leave it even if it has no constraints... this is only to make editing easier
In other words, the View will "stay where you leave it" until you add constraints.
The reason it looks different in the Preview vs your app is because anything in your XML with
tools: is going to be removed from the code when your app runs. These options are only for the Android Studio layout editor, not representative of what you should expect to see when the code runs.
And it may be troublesome for beginners because
a missing constraint won't cause a compilation error
the Layout Editor indicates missing constraints as an error in the toolbar. To view the errors and other warnings, click Show Warnings and Errors (red button with number). To help you avoid missing constraints, the Layout Editor can automatically add constraints for you with the Autoconnect and infer constraints features
add this in xml to the button etc
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.57"
then play with it in the design.
Good luck! :)
Basically this type of problem happens when you use ConstraintLayout .
So Go to Preview From Android Studio.
Select That button you want to set at the specific position
At last just click the infer constrains button as i mention in the picture below on a red circle.
Thats All run the project and see magic