11

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.

zx485
  • 28,498
  • 28
  • 50
  • 59
Medusa
  • 593
  • 2
  • 5
  • 18

3 Answers3

13

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.

Veii Xhen
  • 334
  • 2
  • 12
  • This solves the issue but why? Why it has to be a ConstraintLayout? I need it to be a RelativeLayout for other purposes, could you explain your solution? – Cliff Burton Nov 08 '17 at 16:09
  • @Cliff Burton I suppose they both serves different purposes. As stated by some Constraint Layout is newer and can do more than Relative Layout. Check [this](https://stackoverflow.com/questions/37321448/differences-between-constraintlayout-and-relativelayout?noredirect=1&lq=1) out because they can explain better. – Veii Xhen Nov 09 '17 at 04:21
10

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?

Dave Coleman
  • 101
  • 1
  • 2
0

You have to add the v7 appcompat support library in gradle. so you can add android.support.v7.widget.Toolbar in xml layout.

Jayaprakash
  • 101
  • 5