Android Studio预览片段

问题描述:

我有以下布局文件:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent">

    <TextView
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="@string/what_did_you_eat"/>

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:context=".AddFoodActivity"
        tools:ignore="MergeRootFrame"
        />

</LinearLayout>

FrameLayout将包含动态添加的fragment,是否可以在编辑器中预览fragment? 就像我们在将< fragment> 标签与 tools:layout 属性一起使用时所做的一样?

FrameLayout will contain a dynamic added fragment, is there a way to preview in the editor the fragment ? Like we can do when using a <fragment> tag with the tools:layout attribute ?

虽然有用,但当前的工具文档表明这是可能的.

While it would be useful, there's nothing in the current tools docs that suggests this is possible.