我第一次学习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>
答案 0 :(得分:0)
It seems that a lot of your widgets actually do not have constraints. Remove the tools:ignore="MissingConstraints" attribute to see the missing ones. Every widget needs to be constrained at least with two constraints (one for the vertical axis, one for the horizontal axis).
Things display correctly in the layout editor simply because it's much nicer to keep the widgets where you put them while you are designing things, even if they don't have constraints. But on device, those fixed positions are not used.