我有兴趣尝试 Android Studio 中显示的导航图。但是我导入 google sample 后预览不可用
我使用的是 Android Studio 3.2 Preview Canary 16
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:startDestination="@+id/launcher_home">
<fragment
android:id="@+id/launcher_home"
android:name="com.android.samples.arch.componentsbasicsample.StartFragment"
android:label="Home">
<action
android:id="@+id/end_action"
app:destination="@id/end_dest" />
</fragment>
<fragment
android:id="@+id/end_dest"
android:name="com.android.samples.arch.componentsbasicsample.EndFragment"
android:label="End"
>
</fragment>
</navigation>
2018 年 10 月 6 日更新:
即使我重新构建项目也无法正常工作。但如果添加新屏幕,它会在预览模式下显示新屏幕
最佳答案
您应该在导航编辑器(导航图的 xml 文件)中单击“文本”选项卡,然后添加:
tools:layout="@layout/layout_name"
在目标元素内。
应该是这样的:
<fragment
android:id="@+id/someFragment"
android:name="com.freesoulapps.navigationtest.fragments.SomeFragment"
android:label="Some Fragment"
tools:layout="@layout/layout_name">
</fragment>
关于android - 导航预览在 Android Studio 3.2 预览版中不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50776284/