我可以定义一个在Android中包含样式的样式吗?

我可以定义一个在Android中包含样式的样式吗?,android,android-resources,android-styles,Android,Android Resources,Android Styles,我创建了以下样式: <style name="wrap_content"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> </style> 包装内容 包装内容 我想创建使用此样式的第二个样式。我知道我可以做到以下几点: <sty

我创建了以下样式:

<style name="wrap_content">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
</style>

包装内容
包装内容
我想创建使用此样式的第二个样式。我知道我可以做到以下几点:

<style name="cycle_radio_button" parent="wrap_content">
    <item name="android:layout_marginStart">1dp</item>
    <item name="android:layout_marginEnd">1dp</item>
</style>

1dp
1dp
但是,有没有一种方法可以替代以下方法:

<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>

1dp
1dp
@样式/包装内容

如果可以的话,基于我定义的多个其他样式创建一个样式会更容易、更清晰,而不必创建一个继承样式链。

在Android中不能从多个xml样式继承。最接近这一点的是为特定类型的视图继承样式。例如:

<style name="style1" parent="Theme.AppCompat.Light">
    <item name="android:listViewStyle">@style/wrap_content</item>
    <item name="android:mapViewStyle">@style/AppTheme</item>
</style>

@样式/包装内容
@样式/应用主题
现在,任何从“style1”继承的列表视图或地图视图都将继承“wrap\u content”中的样式


name=“android:listViewStyle”
这样的属性只适用于特定的视图类型,因此这并不能完全满足您的需要。

感谢您的回答,Benstrom。很高兴听到这个消息!如果这已经回答了你的问题,请随意将其标记为正确答案。