我应该在我的主布局之上膨胀或 <include /> 一个新布局吗?
Should I Inflate or <include /> a new layout on top of my main layout?
我对应用程序主布局中其他布局的呈现有些困惑。
我知道 inflate,我经常使用它,但几天前我遇到了 < include />
可以直接在应用程序的主要 xml 布局中使用,它更快更干净。
喜欢:
<include
android:layout_width="fill_parent"
android:layout_height="50dp"
layout="@layout/titlebar" />
这两个有什么区别?
不同的是,一个是在你的代码中完成的,另一个是Android完成的。 Include 似乎是一个不错的选择,但它与 <merge>
结合使用效果更好,因为它不需要额外的 ViewGroup,从而使您的 UI 在测量传递为 运行 时更快。进一步阅读 on the google's training website
我对应用程序主布局中其他布局的呈现有些困惑。
我知道 inflate,我经常使用它,但几天前我遇到了 < include />
可以直接在应用程序的主要 xml 布局中使用,它更快更干净。
喜欢:
<include
android:layout_width="fill_parent"
android:layout_height="50dp"
layout="@layout/titlebar" />
这两个有什么区别?
不同的是,一个是在你的代码中完成的,另一个是Android完成的。 Include 似乎是一个不错的选择,但它与 <merge>
结合使用效果更好,因为它不需要额外的 ViewGroup,从而使您的 UI 在测量传递为 运行 时更快。进一步阅读 on the google's training website