【发布时间】:2019-08-19 17:03:07
【问题描述】:
我正在尝试学习 Android 开发。我正在单击“Empty Activity”的模板,该模板显示了一个带有后退按钮的漂亮材质工具栏。但是,当我查看主布局 xml 文件时看不到它。难道我做错了什么?它应该是这样的吗?该教程显示它与我的不同:
教程显示材质工具栏:
这是我重现问题的视频:https://imgur.com/a/6fMaCki
这是 Android Studio 为我创建的 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
【问题讨论】:
-
Android studio 不久前更改了这些模板,可能您尝试遵循的 codelab 已过时。
-
我看到的模板与教程中的模板相同,并在几天前安装了新的 Android Studio。
-
你有这个codelab的链接吗?好像没找到。
-
据我所知,你的代码完全相同,可能是Android Studio内部的渲染在过去半年发生了变化,所以他们不再显示了。继续codelab,当你在设备上运行时,它看起来会很好。
标签: android-studio android-layout material-design android-xml