Issue
I created the following style:
<style name="wrap_content">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
I want to create a second style that uses this style. I know I can do the following:
<style name="cycle_radio_button" parent="wrap_content">
<item name="android:layout_marginStart">1dp</item>
<item name="android:layout_marginEnd">1dp</item>
</style>
But is there a way to do instead something like the following:
<style name="cycle_radio_button">
<item name="android:layout_marginStart">1dp</item>
<item name="android:layout_marginEnd">1dp</item>
<item name="style">@style/wrap_content</item>
</style>
If I could, creating a style based on multiple other styles I have defined would be easier and clearer, rather than having to create a chain of inherited styles.
Solution
You cannot inherit from multiple xml styles in Android. The closest thing to that is to inherit a style for a particular type of view. For instance:
<style name="style1" parent="Theme.AppCompat.Light">
<item name="android:listViewStyle">@style/wrap_content</item>
<item name="android:mapViewStyle">@style/AppTheme</item>
</style>
Now, any list views or map views which inherit from "style1" will inherit the styling in "wrap_content".
Attributes like name="android:listViewStyle"
only apply to specific view types, so this is not going to do exactly what you want.
Answered By - Benstrom
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.