我正在尝试通过样式放大所有应用程序对话框按钮上的文本大小。以下代码将更改按钮背景颜色,甚至更改文本大小写,但由于某种原因,textSize 项目不受支持:
<style name="MyAppTheme" parent="@android:style/Theme.Holo">
<item name="android:dialogTheme">@style/MyApp.Dialog</item>
<item name="android:alertDialogTheme">@style/MyApp.Dialog.Alert</item>
</style>
<style name="MyApp.Dialog" parent="@android:style/Theme.Holo.Dialog">
<item name="android:borderlessButtonStyle">@style/MyApp.BorderlessButton</item>
</style>
<style name="MyApp.Dialog.Alert" parent="@style/MyApp.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<style name="MyApp.BorderlessButton" parent="@android:style/Widget.Holo.Button.Borderless">
<item name="android:textSize">50sp</item>
<item name="android:textAllCaps">true</item>
<item name="android:background">#800</item>
</style>
为什么 textSize 没有被读取?我需要做什么才能让它变大?
您没有在这里分配正确的属性:
<style name="MyApp.Dialog" parent="@android:style/Theme.Holo.Dialog">
====> <item name="android:borderlessButtonStyle">@style/MyApp.BorderlessButton</item>
</style>
您需要使用的属性是:
android:buttonStyle
我建议进行以下更改:
<style name="MyApp.Dialog" parent="@android:style/Theme.Holo.Dialog">
<item name="android:buttonStyle">@style/MyApp.BorderlessButton</item>
</style>
Why:
borderlessButtonStyle
是一种方便定义的样式。但它当前未连接到任何默认属性 - 在本例中,buttonStyle
。您仍然需要分配它。
我不明白为什么background
and textAllCaps
属性生效。发布对话框/警报对话框的 xml 可能会有所帮助。另外,你如何定义字符串 - “我同意”或“我同意”?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)