【发布时间】:2018-12-18 09:38:39
【问题描述】:
我是 Android 开发的初学者,所以我决定下载 Android Studio。
我创建了一个项目,在尝试构建应用程序的前几次尝试编译器给出了一个错误,因为我丢失了一些文件,所以我安装了它们。
我的问题是,当它最终完成构建应用程序时,即使显示它存在于组件树中,我也看不到 Hello Word 文本视图,我添加了另一个文本视图并我一松开鼠标按钮它就消失了。这也发生在我尝试使用的所有其他组件上,按钮、图像、视图等等。
我还注意到,通过单击左上角组件树上的一个组件,将显示 2 个按钮:一个带有 imo 表示它应该从布局中删除组件的符号,另一个带有“ ab" 我不知道是什么意思。这表明我应该出于某种原因将组件卡在那里。
感谢您的关注,
若昂·奥利维拉
PS:
链接
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>
【问题讨论】:
-
您忘记添加约束布局的结束标记
-
看看是否有效
-
@Opriday 它已关闭但不在该行,在 tools:context=".MainActivity" 之后有一个右括号。除了设计视图之外,我没有弄乱任何视图。你知道会发生什么吗?
-
您的目标是哪个 SDK 和支持版本?我注意到使用 28.0.0-alpha3 会在预览中出现错误,尽管应用程序按预期构建和运行。尝试将 SDK 更改为 27 并支持到 27.0.0。
-
android-26 表示,转到 skd 管理器,Sdk 平台然后检查 API 级别 26 平台是否安装。如果未安装,则安装并同步 gradle 或重建项目。
标签: android android-studio build