将重用布局添加到滚动视图

Add re-using layout to scroll view

我想添加到 XML 文件(包括一个滚动视图),使用此代码重新使用布局: <include layout="@layout/titlebar"/> .但是出现这个错误:

Exception raised during rendering: ScrollView can host only one direct child

我应该如何将此标签添加到 XML 文件?

如异常文本所述,ScrollView 中不能有多个子项。为了修复它,只需将 ScrollView 的内容,包括您的 include,包装到布局中(例如 LiniearLayout 或您需要的套件)。