问题描述
这就是我设置按钮的方式.
This is how I set my buttons.
<Button
android:id="@+id/button_login"
style="@style/ButtonStyle"
android:text="@string/button_login" />
这是我在values文件夹上的样式.
This is my style on values folder.
<style name="ButtonStyle" parent="ButtonStyleBase" />
<style name="ButtonStyleBase">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginTop">@dimen/padding</item>
<item name="android:textSize">@dimen/font_regular</item>
<item name="android:textColor">@color/text_regular</item>
<item name="android:background">@drawable/shape_clickable</item>
</style>
这是我在values-v21文件夹上的风格
And this is my style on values-v21 folder
<style name="ButtonStyle" parent="ButtonStyleBase">
<item name="textAllCaps">false</item>
<item name="android:textColor">#000000</item>
</style>
但是按钮上的文本始终是大写的.但是,如果我直接将其设置在按钮上,它将恢复正常.我更改了颜色以查看是否正在使用api 21的样式,并且在api 21上按钮文本的颜色更改为黑色.我知道默认主题将按钮的textAllCaps设置为true,因为Google认为它会超级重复-cool,但是它不应该优先考虑我的风格吗?
But the text is always uppercase on buttons. If I set it directly on the button it will get back to normal, though. I changed the color to see if the style for api 21 was being used and it was, the button text color changed to black on api 21. I know the default theme sets textAllCaps as true for buttons because google thought it would be super-duper-cool, but shouldn't it prioritize my style?
没关系,我忘了在样式上写"android:".
neverming, I forgot to write "android:" on the style.
推荐答案
我遇到了同样的问题,这对我有用:
I had the same issue and this is what worked for me:
<style name="Theme.CustomTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:textAppearanceButton">@style/CustomTheme.ButtonTextAppearance</item>
</style>
<style name="CustomTheme.ButtonTextAppearance" parent="@style/Base.TextAppearance.AppCompat.Button">
<item name="textAllCaps">false</item>
<item name="android:textAllCaps">false</item>
</style>
希望这会有所帮助.
这篇关于无法覆盖android 21下样式上的按钮的textAllCaps的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!