Monday, April 23, 2018

When Android Studio complains about lack of constraints

Recently I tried to put together a UI layout for an Android application. I found that all the UI elements would fly to the upper left at runtime even though they were placed as intended in the designer. There was a warning exclamation mark next to them in the component tree noting that they had no constraints. Some Googling turned up a mention of a wand icon in the designer toolbar that automatically creates constraints. Indeed it does, and that made the elements stay in their place at runtime.

I still found the ConstraintLayout unwieldy, though, so I ended up changing the root layout to a LinearLayout by right-clicking it in the component tree and using the "convert view" command.

No comments:

Post a Comment