【发布时间】:2019-02-01 02:52:32
【问题描述】:
我刚开始使用来自 android.com 的 Build your first app 教程,但由于某种原因,设计视图没有显示我拖放到其中的任何内容。我尝试创建按钮、文本、纯文本等,都没有错误,但是,我只能在运行应用程序时看到它。 我错过了什么?
在 Ubuntu 18.04.1 LTS 上运行 Android Studio 3.1.4。
这是我第一次使用它,我在发布之前搜索了类似的问题,只发现与我的问题不够相似的问题/答案没有帮助。我尝试重建缓存/重新启动并使缓存无效,但无济于事。
这里有一些快照:
最后是activity_main.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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:text="@string/title_home"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="KoDy Abbott"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
如果您需要其他任何东西来帮助回答我的问题,请告诉我。提前谢谢你,希望我忽略了一些简单的事情,但此时我更容易问,然后再敲几个小时......
【问题讨论】:
-
默认主题会导致这个问题,我个人认为它对新开发者非常不友好!
-
尝试在设计部分更改api级别或主题。
标签: android xml android-layout android-studio