Редактор макета Android Studio

Привет, я только начал использовать редактор макетов Android Studio, поэтому я только что создал новый проект с базовыми действиями, так что он просто имеет текст приветствия в середине. Я выполнил все инструкции: https://developer.android.com/training/basics/firstapp/building-ui Но у меня ничего подобного нет, у меня просто синий прямоугольник, на котором ничего нет. Я заметил несколько ошибок на вкладке сообщений об ошибках и предупреждениях:

1 Rendering Error
Failed to find style 'coordinatorLayoutStyle' in current theme   Tip: Try to refresh the layout. 
1 Using Private resources: 
The resource @string/appbar_scrolling_view_behavior is marked as private in com.android.support:design  Private resources should not be referenced; the may not be present everywhere, and even where they are they may disappear without notice.  To fix this, copy the resource into your own project instead.
1 Missing Styles:
Missing styles. Is the correct theme chosen for this layout?  Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.
1 Failed to instance one or more classes
The following classes could not be instantiated:
- android.support.design.widget.CoordinatorLayout (Open Class, Show Exception, Clear Cache)
- android.support.design.widget.AppBarLayout (Open Class, Show Exception, Clear Cache)
 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  If this is an unexpected error you can also try to build the project, then manually refresh the layout.  Exception Details java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener Copy stack to clipboard

Я понятия не имею, почему это происходит, поскольку я совсем недавно установил Android Studio и не ожидал никаких ошибок с новым базовым проектом. Надеюсь, ты сможешь помочь, спасибо!

Обновлено: XML-ТЕКСТ ПОСЛЕ УДАЛЕНИЯ ПРИВЕТСТВЕННОГО МИРА И ПРОСТОГО ПЕРЕТАЩЕНИЯ И ОТКЛЮЧЕНИЯ РЕДАКТИРОВАНИЯ ТЕКСТА

<?xml version = "1.0" encoding = "utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android = "http://schemas.android.com/apk/res/android"
    xmlns:app = "http://schemas.android.com/apk/res-auto"
    xmlns:tools = "http://schemas.android.com/tools"
    android:layout_width = "match_parent"
    android:layout_height = "match_parent"
    tools:context = ".MainActivity">

    <EditText
        android:id = "@+id/editText"
        android:layout_width = "wrap_content"
        android:layout_height = "wrap_content"
        android:ems = "10"
        android:inputType = "textPersonName"
        android:text = "Name"
        tools:layout_editor_absoluteX = "126dp"
        tools:layout_editor_absoluteY = "158dp" />
</android.support.constraint.ConstraintLayout>

ДРУГОЕ РЕДАКТИРОВАНИЕ: при наведении курсора на EditText (поскольку он подчеркнут красным) он говорит, что это представление не ограничено.

0
0
540
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Вы используете макет ограничения, но ваше текстовое представление использует абсолютную позицию. tools:layout_editor_absoluteX = "126dp" и tools:layout_editor_absoluteY = "158dp".

https://developer.android.com/training/constraint-layout/

<TextView
    android:layout_width = "wrap_content"
    android:layout_height = "wrap_content"
    android:text = "Hello World!"
    app:layout_constraintBottom_toBottomOf = "parent"
    app:layout_constraintLeft_toLeftOf = "parent"
    app:layout_constraintRight_toRightOf = "parent"
    app:layout_constraintTop_toTopOf = "parent" />

Кроме того, тема вашего приложения ищет координаторLayout.

<style name = "AppTheme.NoActionBar">
  <item name = "coordinatorLayoutStyle">@style/Widget.Design.CoordinatorLayout</item>
</style> 

Другие вопросы по теме