android - 创建从应用程序主题中设置的默认样式扩展的样式
问题描述
我在我的应用程序主题中设置了默认按钮样式,以便将其应用于应用程序中的每个按钮。
除了默认样式外,很少有按钮需要将其文本大写。所以我想要做的是这样的事情
(以下代码片段不起作用,因为我无法设置parent="?attr/materialButtonStyle"
):
<style name="capitalizedButton" parent="?attr/materialButtonStyle">
<item name="android:textAllCaps">true</item>
</style>
是否可以扩展在 theme.xml 中定义的样式?我不想引用我在主题中设置的本地样式,因为以后可能会更改,而是打算使用主题属性访问它。
解决方案
您可以直接将样式传递给Button
XML 中的小部件,例如:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="capitalizedButton"/>
希望你能得到答案。如果不是,请解释您的问题。
推荐阅读
- swift - 用于时间序列分析的 Core ML
- vb.net - 3d坐标系中两点之间的间距
- python - 使用 psycopg2 复制到带有 ARRAY INT 列的表
- c++ - 声明和定义之间的冲突是否会导致未定义的行为?
- javascript - 更新 Cypress 3.1.2 版本后无法打开 Cypress 应用程序
- reactjs - 电子错误启动应用程序无法找到电子应用程序
- oracle - 使用 count(*) 在 SQL 过程中获取多于一行
- mysql - mysql选择范围内的日期时间对象
- hyperledger-cello - 无法登录到 Hyperledger Cello 操作员仪表板
- vue.js - 在vue js中使用数组列表预先输入