我从 android studio 开始,看不到元素(按钮、TextView、..)我拖放到 activity_main.xml
页面中的设计页面。这些元素存在于我的 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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:layout_editor_absoluteY="25dp">
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_home"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:menu="@menu/navigation" />
<Button
android:id="@+id/button"
android:layout_width="12dp"
android:layout_height="12dp"
android:text="ClickMe"
tools:layout_editor_absoluteX="-73dp"
tools:layout_editor_absoluteY="29dp" />
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="20dp" />
</android.support.constraint.ConstraintLayout>
我的画布完全是空的。
编辑 :
我有 2 个错误:
渲染问题:
Failed to find style 'bottomNavigationStyle' in current theme Tip: Try to refresh the layout.
ConstraintLayout 中缺少约束:
This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints
原文由 user9007028 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可以通过修复 styles.xml 文件来解决此问题。
然后你只需要在这段代码中添加 Base :
最终代码: