Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't find the toolbar in the layout editor in Android Studio

I'm trying to do the Android Developer Tutorial.

They refer to the toolbar in the layout editor, in the tutorial picture it looks like this:

enter image description here

But this is what I see

enter image description here.

The toolbar with the eye is missing. As you see, there is a "Toolbar"-Icon in the menu, but clicking it has no effect.

I'm using Android Studio 2.3 and followed the previous lessons of the tutorial as demanded. How can I activate this toolbar?

This is the link for building an Android UI.

like image 817
Medusa Avatar asked Mar 09 '17 15:03

Medusa


2 Answers

The tutorial was written before the split between activity_main.xml and content_main.xml. This split was made in Android Studio 1.4. activity_main.xml is the main file, which includes content_main.xml in the line:

<include layout="@layout/content_main" />

If you follow the tutorial exactly, it's having you open activity_main.xml, which doesn't have any of the real "stuff" in it. Since activity_main doesn't have the TextView that the tutorial is trying to get you to look at, you don't get the correct toolbar icons populating to do the next few steps.

Short story: In the section "Open the Layout Editor", under Step 1, you should open content_main.xml instead of the activity_main.xml that's indicated. Things should be smooth from there.

For more information about the difference between activity_main.xml and content_main.xml, see What is the role of content_main.xml in android studio 1.4?

like image 150
Dave Coleman Avatar answered Sep 24 '22 05:09

Dave Coleman


Was having this exact issue. Spent an hour looking for a solution for this, and turns out it was really easy. Note that you will need android studio version > 2.2.

In the activity_main.xml, look for the component tree. Likely there is a Linear_Layout or Relative_Layout. Just right click and then click 'Convert to Constraint Layout'. Done.
This is the result: image.

Hope this helps. Happy coding.

like image 22
Veii Xhen Avatar answered Sep 20 '22 05:09

Veii Xhen