I abandoned the studio for half a year, now I downloaded the latest version and I can’t understand anything. Now CustomView are used in templates, and I cannot add anything to this layout . Teach a teapot how graphic layout editing is now implemented? Those. now it is not possible to drag views to the layout, but only in a separate layout and pick up the include , but this is very inconvenient and binds the hands.
1 answer
There are no changes in the visual editor itself that could lead to such "problems" in the general case of its use, however there are nuances in its work.
You had such difficulties, firstly, because you do not fully understand the markup structure in the latest default templates proposed by Google.
The markup activity_main.xml within this template is not intended for placing custom widgets, it serves as the root container and implements only the animated interaction of the FAB and Snakbar - the widgets you need, content, etc. that you consider necessary to display on the screen, according to Google’s idea, you should post markup fragment_main.xml , which generally covers 99% of the needs of fans to write applications using templates.
Secondly, the "glitch" itself about the fact that it is impossible to "throw" the widget in the visual editor assumes that, according to this visual editor, the markup activity_main.xml in this template does not contain containers that could accommodate the widgets. More precisely, the CoordinatorLayout is essentially FrameLayout and, of course, may contain widgets, but the visual editor is not yet able to determine this for containers that are not basic (CustomView). Let's hope that someday it will be fixed, but in the meantime, if you really want to edit activity_main.xml , in spite of Google’s proposed Google Case, you have the following options:
You can solve this problem radically by creating your own markup.
Right-click on theres/layoutfolder and follow the New -> Layout resource file . A wizard for creating new markup will appear, where you need to specify its name and the root container, for example,LinearLayout. Then you can work with this markup in the visual editor you like so much.You can add any base container in manual editing mode (Text). For example, replacing a fragment call (
include @layout/content_main) with someLinearLayout. After that you can "throw" widgets there in the visual editor.You can exhale and refuse to use the visual editor, which is mostly useless and sometimes even harmful, and create markup in manual editing mode (Text), using the visual editor only for viewing the result. Then you can add anything and anywhere, in response to the maximum that awaits you, this application will not gather into something working.
- The third point is 100% correct) - YuriySPb ♦
xml, only hardcore! - Yuriy SPb ♦