【问题标题】:Two Errors in Android StudioAndroid Studio 中的两个错误
【发布时间】:2018-09-26 21:11:37
【问题描述】:

我是使用 Android Studio 的新手,但我在 Java 方面还不错。所以我尝试在 Android Studio 中创建一个 Hello World 类,但没有成功。 ide 给出了两个错误,我不知道该怎么做。这是给我“属性缺少 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>

下一段代码给了我这个错误“视图不受约束。它只有设计时位置,所以它会在运行时跳转到 (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" />

好吧,我正在尝试按照本教程学习如何设置 Android Studio 以及如何在其上制作程序。好吧,视频中的那个人在加载他的程序时没有收到任何东西,但我收到了。

【问题讨论】:

标签: android xml android-studio


【解决方案1】:

第一个错误是name引起的,应该是android:name

第二个错误是当您使用“约束布局”并且不添加任何约束时引起的。我建议在这里查看布局概述:https://developer.android.com/guide/topics/ui/declaring-layout

然后看看这个关于约束布局的视频:https://developer.android.com/training/constraint-layout/

【讨论】:

    猜你喜欢
    • 2018-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-08
    • 2017-12-16
    • 2013-09-14
    • 2017-08-01
    相关资源
    最近更新 更多