视图卡在左上角(Android Studio)

时间:2018-07-10 13:46:29

标签: android android-studio build

我是Android开发的入门者,因此决定下载Android Studio。
我创建了一个项目,在最初的几次尝试构建App的过程中,编译器出现错误,因为我缺少一些文件,因此我安装了它们。

我的问题是,当它最终完成构建应用程序时,即使显示它已存在于组件树中,我也看不到 Hello Word 文本视图,我添加了另一个文本视图并释放鼠标按钮后,它便消失了。我尝试过的所有其他组件,按钮,图像,视图以及所有其他东西也都发生了这种情况。

我还注意到,通过单击左上角组件树上的一个组件,将显示2个按钮:一个带有imo表示应从布局中删除该组件的符号,另一个带有一个“ ab”,我不知道这意味着什么。这表明我出于某些原因应将组件卡在其中。

感谢您的关注,

JoãoOliveira

P.S .:

链接
Components seem to be stuck in the Top Left Corner
Text View is not visible

activity_mail.xml中的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">

<TextView
    android:id="@+id/sample_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="1.0" />

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0" />
    </android.support.constraint.ConstraintLayout>

2 个答案:

答案 0 :(得分:0)

您的视图就在您约束它们的地方。而且看不到1dp大小的视图,这是您的代码:

android:layout_width="1dp"
android:layout_height="1dp"

使视图大小正确,您将看到它。

答案 1 :(得分:0)

    <?xml version="1.0" encoding="utf-8"?><?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">

    <TextView
        android:id="@+id/sample_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="1.0" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>

enter image description here

相关问题