-3

我是第一次学习 Android Studio,但我一直在尝试在物理 android 设备上运行程序。我遇到的问题是我的任何内容(小部件、文本视图、按钮)都没有出现在我设备的屏幕上。我使用的电脑有问题吗?我可以在编辑器中查看和操作小部件,但我在屏幕上创建的很多东西并没有显示在正确的位置,除了蓝图。

我已经附上了所有的图片,所以你们可以看看。我在 AMD A10-9600p Radeon R5 上运行它。谢谢您的帮助。

<?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:ignore="MissingConstraints">

<TextView
    android:text="TextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textView2"
    tools:ignore="UnknownId"
    tools:layout_editor_absoluteY="42dp"
    android:layout_marginStart="16dp"
    app:layout_constraintLeft_toLeftOf="@+id/constraintLayout"
    android:layout_marginLeft="16dp" />

<EditText
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:inputType="textMultiLine"
    android:ems="10"
    android:id="@+id/editText"
    android:layout_marginTop="16dp"
    app:layout_constraintTop_toBottomOf="@+id/textView2"
    android:layout_marginStart="16dp"
    app:layout_constraintLeft_toRightOf="@+id/textView2"
    android:layout_marginLeft="16dp"
    tools:ignore="UnknownId"
    android:text="Hello this is my first app and I have no clue what I'm     doing! Hopefully this all works out! I just need a bunch of words so i can create scorolling i am just typing things as fast as i can its problaly mispselled but who realy gives a hooot! just like the pokemon. this comupuete is decent but the bang for the buck is where its at. I caould make raps for fday s but its ok oops i guess i need some more word so this lovely app can scroll like a bouss hog out of the kitchen i think ill go get some ice cream soon yes great idea mr culver holla at ur boy yes"
    app:layout_constraintBottom_toTopOf="@+id/button3"
    android:layout_marginBottom="16dp"
    app:layout_constraintHorizontal_bias="0.75"
    app:layout_constraintVertical_bias="0.8"
    android:layout_marginEnd="16dp"
    app:layout_constraintRight_toRightOf="@+id/constraintLayout"
    android:layout_marginRight="16dp" />

<Button
    android:text="CANCEL"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/button2"
    tools:ignore="UnknownId"
    tools:layout_editor_absoluteY="436dp"
    tools:layout_editor_absoluteX="268dp" />

<Button
    android:text="OK"
    android:layout_width="88dp"
    android:layout_height="48dp"
    android:id="@+id/button3"
    app:layout_constraintRight_toLeftOf="@+id/button2"
    android:layout_marginEnd="16dp"
    android:layout_marginRight="16dp"
    tools:ignore="UnknownId"
    app:layout_constraintBaseline_toBaselineOf="@+id/button2" />
</android.support.constraint.ConstraintLayout>

来自 Android 设备的图像

Android Studio 截图

4

1 回答 1

1

似乎您的许多小部件实际上都没有约束。删除 tools:ignore="MissingConstraints" 属性以查看丢失的属性。每个小部件都需要至少受到两个约束(一个用于垂直轴,一个用于水平轴)。

事物在布局编辑器中正确显示只是因为在设计事物时将小部件保留在放置它们的位置要好得多,即使它们没有约束。但是在设备上,这些固定位置没有被使用。

于 2016-10-20T18:33:52.450 回答