【问题标题】:Android have a style add properties instead of replacing propertiesAndroid有一个样式添加属性而不是替换属性
【发布时间】:2015-12-11 21:07:47
【问题描述】:

可能不是一个非常明确的问题,但问题是这样的:

我有一个样式叫Button,这个样式包含几个属性。

有一个属性仅适用于 API-21 >

于是我在styles-v21中创建了一个Button样式,如下所示:

<style name="Button"> <item name="android:stateListAnimator">@null</item> </style>

所有其他属性都丢失了。有没有办法将样式的 Button 与 styles-v21 的 Button 合并?

【问题讨论】:

  • 让样式继承自您想要的基本样式。

标签: android xml styles


【解决方案1】:

你必须扩展父样式:

<style name="Button" parent="Widget.AppCompat.Button">
    <item name="android:stateListAnimator">@null</item>
</style>

您可以将“Widget.AppCompat.Button”替换为任何其他按钮样式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-14
    • 2016-02-26
    • 1970-01-01
    • 2017-08-30
    • 1970-01-01
    • 2014-12-07
    • 2021-11-09
    • 1970-01-01
    相关资源
    最近更新 更多