Android Studio 预览片段

4

i have the following layout file:

<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属性时所做的那样。


在接受的答案中,有一个重定向到文档。我查了一下工具文档,但是没有找到答案。你能否发布确切的解决方案? - LunaVulpo
1个回答

4

2
你可以像布局章节中所描述的那样,在FrameLayout下嵌套fragment标签,它会正常工作。 - fo2rist

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接