我在 xml
中重复了很多控制(例如,一个 Button
)。是否有可能在 xml
中编写一次 Button
然后将其导入我需要的所有布局中?
最佳答案
你可以使用
<include layout="@layout/commonlayout" android:id="@+id/id" />
commonlayout.xml
应该定义在 res/layout
中,您可以在其中添加重复的部分。
关于android - 将 xml 导入另一个 xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4132362/