I am including an (internal) layout in my own layout like this:
<include android:id="@+id/twolinelistitem"
layout="@android:layout/simple_list_item_2"
style="@style/TwoLineListItem"/>
but the style is not applied. This blog post doesn't mention that this should work so I'm okay if it doesn't.
So the only way to set i.e. the background is programmatically?
Here is a somewhat related android Issue
To efficiently re-use complete layouts, you can use the <include/> and <merge/> tags to embed another layout inside the current layout. Reusing layouts is particularly powerful as it allows you to create reusable complex layouts. For example, a yes/no button panel, or custom progress bar with description text.
Include Tag:The <include/> tag helps us to include the xml content's in our xml file. This is a nice way to share layout parts between different layout's. Suppose we need to show the custom title in many layouts, for that we simply create a custom layout for title bar and then reuse the layout by using <include/> tag.
Unfortunately, this does not seem to be possible. Only the layout parameters (if both height and width are set...), id, and visibility are passed from the include tag to the actual layout. Setting a style on the include tag does not seem to have an effect.
You can see the source code for parsing an include here.
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