简体   繁体   English

Android Studio 中的两个错误

[英]Two Errors in Android Studio

I am new at using Android Studio, but I am quite alright in Java.我是使用 Android Studio 的新手,但我在 Java 方面还不错。 So I tried to make a Hello World class in Android Studio and it didn't work.所以我尝试在 Android Studio 中创建一个 Hello World 类,但没有成功。 The ide gave two errors I had no clue what to do.该ide给出了两个错误,我不知道该怎么做。 Here is the piece of code that was giving me the "Attribute is missing the Android namespace prefix"这是给我“属性缺少Android命名空间前缀”的一段代码

    <style name="AppTheme.NoActionBar">
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <item name="coordinatorLayoutStyle">
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content">
        @style/Widget.Design.CoordinatorLayout</item>
    </style>

This next piece of code gives me this error "The view is not constrained. It only has designtime positions, so it will jump to (0,0), at runtime unless you add the constraints."下一段代码给了我这个错误“视图不受约束。它只有设计时位置,所以它会在运行时跳转到 (0,0),除非你添加约束。”

<EditText
    android:id="@+id/HelloWorld"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="textPersonName"
    android:text="Hello World"
    android:textColor="?android:attr/colorBackground"
    tools:layout_editor_absoluteX="70dp"
    tools:layout_editor_absoluteY="91dp" />

Well, I was trying to follow this tutorial on how to set up Android Studio and how to make a program on it.好吧,我试图按照本教程学习如何设置 Android Studio 以及如何在其上制作程序。 Well, the guy in the video didn't receive any when he loaded up his program but I did.好吧,视频中的那个人在加载他的程序时没有收到任何消息,但我收到了。

The first error is caused by name it should be android:name第一个错误是由name引起的,它应该是android:name

The second error is caused when you use a "Constraint Layout" and don't add any constraints.当您使用“约束布局”并且不添加任何约束时会导致第二个错误。 I suggest looking at the layout overview here: https://developer.android.com/guide/topics/ui/declaring-layout我建议在此处查看布局概述: https : //developer.android.com/guide/topics/ui/declaring-layout

Then look at this video about constraint layouts: https://developer.android.com/training/constraint-layout/然后看看这个关于约束布局的视频: https : //developer.android.com/training/constraint-layout/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM