mmcib
mmcib

Reputation: 141

Android Studio; Layout; Design view;

In Android Studio 3.1.3 on Windows 7 x64 when in design view of XML file I want to drag-and-drop anything, for example, TextView I can't edit it in design view because I can't see it. I see only it:

enter image description here

On video tutorials, everything is ok as always :/

How can I fix it?

Upvotes: 2

Views: 2452

Answers (2)

Grigoriy
Grigoriy

Reputation: 1

Can you see your buttons and other elements when you run your project on emulator? If yes then you probably got same problem as me. By trial and fail I found that the problem is with backwards compatibility. Try to start new project and uncheck backwards compatibility (that option you've got after selecting activity type for your project). I still can't find a way to fix this and make it work with backwards compatibility enabled. Here is another post on this topic I've found (and either still no answer): android design editor doesn't work with backwards compatibility enabled

Upvotes: 0

Tobias Reich
Tobias Reich

Reputation: 5160

Well, that looks like you just have your Design in blueprint mode. Blueprint mode is just showing outlines of your views. This is usefull when having many small / overlapping views. So if you start with an empty layout you won't see much. If you didn't know about this mode yet, check the button "Select Design Surface (B)" above the blue surface whether it is active? Maybe switching to "design" might help.

enter image description here

However, you can also continue using this. It works exactly as the "design mode". If you add some layout in the Text tab (at the bottom of this view) you should be seeing whether it works or something else is completely wrong.

Try adding some lines like these to your layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:id="@+id/button3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Button" />

</LinearLayout>

Now you hopefully see whether the blueprint changes. So at least you know whether the designer is broken or just the view. If everything works fine you should see something like this:

enter image description here

The editor is also a bit picky about errors. You didn't provide your XML layout but in case of errors, the designer might have trouble rendering the view.

You can see errors on the top right of this view - a red "!" (exclamation mark).

enter image description here

If you click on it you get more details. For instance if you forgot to set the width or height of a view you get an error message as follows:

enter image description here

If you go anything like this, try solving the errors (next time provide the XML layout if there is any).

Last but not least, be aware that while gradle is building your project the designer is not working. You should getting a message though. However try the usual suspects (invalidate, clear, rebuild, restart AS, ...) if nothing works.

Upvotes: 2

Related Questions