通过款式变化的Andr​​oid对话框按钮文字大小 [英] Change Android Dialog button text size via styles

查看:151
本文介绍了通过款式变化的Andr​​oid对话框按钮文字大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过款式放大所有我的应用程序对话框按钮上的文本大小。下面code将改变按钮背景颜色,甚至在文本的情况下,但由于某些原因TEXTSIZE项未兑现:

I am trying to enlarge the text size on all of my applications dialog buttons via styles. The following code will change the buttons background colour and even the text case but for some reason the textSize item is not honoured:

<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没有被读取?我有什么做的,使其更大?

Why is the textSize not being read? What do I have to do to make it larger?

推荐答案

您没有分配权属性的位置:

You are not assigning the right attribute here:

<style name="MyApp.Dialog" parent="@android:style/Theme.Holo.Dialog">
====>    <item name="android:borderlessButtonStyle">@style/MyApp.BorderlessButton</item>
</style>

您需要使用的属性是:

android:buttonStyle

我提出以下变化:

I propose the following change:

<style name="MyApp.Dialog" parent="@android:style/Theme.Holo.Dialog">
    <item name="android:buttonStyle">@style/MyApp.BorderlessButton</item>
</style>

为什么:

borderlessButtonStyle 是一个方便的定义的样式。但目前没有连接到任何的默认属性的 - 在这种情况下,的ButtonStyle 。你仍然需要指定它。

borderlessButtonStyle is a conveniently defined style. But it isn't currently wired to any of the default attributes - in this case, buttonStyle. You still need to assign it.

我不明白,为什么背景 textAllCaps 属性生效。发布您的对话框的/警告对话框中的XML可能的帮助。此外,如何让你定义的字符串? - 我同意或我同意

I can't figure out why the background and textAllCaps attributes come into effect. Posting your dialog's/alert dialog's xml might help. Also, how have you defined the string - "i agree" or "I AGREE"?

这篇关于通过款式变化的Andr​​oid对话框按钮文字大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆