Search code examples
android-relativelayoutandroid-constraintlayout

Android Studio - Constraint Layout Vs Relative Layout Which Is Better?


Why does the items get misplaced in constraint layout, is constraint layout better than relative layout (Newbie Here) Which one is recommended


Solution

  • " but when I create an Activity in a Constraint Layout, the items get misplaced during runtime why is that so?"

    This happens because you must not be adding all the required constraints for your views.

    For example: If your view has only it's top aligned to another view, on rendering, it may move anywhere horizontally since it's left or right isn't aligned.

    I suggest that you look into the official documentation and examples. You could also search for YouTube tutorials on ConstraintLayout.