XML导入另一个XMLXML

2023-09-13 02:30:23 作者:海誓山盟你说给了几个女人

我有很多控制在我的 XML (A 按钮为例)重复。有没有在一个 XML 按钮键,然后导入所有我需要它的布局的可能性?

I have lots of control repeated in my xml (a Button for instance). Is there any possibility to write the Button once in a xml and then import it in all the layout I need it?

推荐答案

您可以使用

<include  layout="@layout/commonlayout" android:id="@+id/id" />

commonlayout.xml RES /布局定义,您可以添加重复的部分。

commonlayout.xml should be defined in res/layout where you can add the repeated parts.