2013-10-25 89 views
3

我有以下布局文件: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预览? 像我们可以做什么时使用<片段>标签与tools:layout属性?

+0

已答复的答案是重定向的文档。我看着工具文档,但我没有看到aswer。你能发布确切的解决方案? – LunaVulpo

回答

1

虽然它会很有用,但the current tools docs没有任何暗示这是可能的。

+1

您可以在'FrameLayout'下嵌套'fragment'标签,就像这里在布局章节https://developer.android.com/reference/android/app/Fragment.html 中所描述的那样它可以工作 –