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?
An XML external entity cannot be a full-blown independent XML document—neither standalone XML declaration nor Doctype declaration is allowed. That effectively means an XML external entity itself cannot include other external entities.
Probably you will have to set within the include tag the properties that sets where it has to be placed: android:layout_above, android:layout_toLeftOf, etc... Use fill_parent instead. I pasted my code and I am working with honeycomb, thats why I was using match_parent. But it should work with fill_parent.
If you import XML data without first adding a corresponding XML schema to create an XML map, Excel tries to infer a schema for you based on the tags that are defined in the XML data file.
You can use
<include layout="@layout/commonlayout" android:id="@+id/id" />
commonlayout.xml
should be defined in res/layout
where you can add the repeated parts.
As Labeeb P rightly said, it works. Just want to add that you can also override parameters too:
<include layout="@layout/commonlayout" android:id="@+id/id" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:layout_marginLeft="2sp" android:layout_marginRight="2sp" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With